1

I can't assign the result of query to variable (the program is written in C). Here is what I do

char buffer[100];

while ((row = mysql_fetch_row(res)) != NULL) {
   buffer = row[0];
}

A get this error during compile process

error: incompatible types in assignment

What is wrong here ?

1
  • What is row? Is it a char array? Commented Dec 16, 2011 at 10:12

1 Answer 1

3

Assuming it's a string? C doesn't have strings it has arrays of characters. So you have copy the characters from one array to another.

so use a copy function like

strncpy(buffer, row[0], 100);
Sign up to request clarification or add additional context in comments.

2 Comments

Also, be sure that a length of 100 is enough.
A note mainly to the question asker: mysql_fetch_lengths can be used to know how long (in bytes) each field is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.