0

char stmt_buf[1024], buf[(1024*2)+1];
stmt_buf ="SELECT id, title FROM post LIMIT 5;";

I get an error:

connect2.c: In function ‘main’:
connect2.c:217: error: incompatible types in assignment

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Narue
0

A more detailed answer is that C doesn't really have a string type. Because there's no string type, we use arrays of char with a special character acting as the end of the string, and all of the rules for arrays apply. In other words, arrays aren't a first class type that can be assigned, so to copy one array to another, you have to use a loop:

size_t n = strlen ( src );
size_t i;

for ( i = 0; i < n; i++ )
  dst[i] = src[i];

dst[i] = '\0';

The strcpy function does that for you, more or less.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.