for example
#include
#include
#include
char substr[10][20];
int main() {
substr[0] = \"abc\";
pr
You can't assign strings like that in C. Instead, use strcpy(substr[0], "abc"). Also, use %s not %d in your printf
Hope this helps:
void main(void)
{
char* string[10];
string[0] = "Hello";
}
Otherwise I think ya need to copy it by hand or use strcpy or the like to move it from one block of memory to another.
I hate giving 'full' answers to homework questions, but the only way to answer your question is to show you the answer to your problem, because it is so basic:
#include <stdio.h>
#include <string.h>
#define MAXLEN 20
char substr[10][MAXLEN];
int main(void) {
strncpy(substr[0], "abc", MAXLEN);
puts(substr[0]);
return 0;
}
Your code (as is) has several faults:
substr[0] as a string literal. You can't do that.%s is for stringsprintf() to print a stringstrncpy()main() doesn't want / need argc and argv, its arguments should be voidmain() should return a value, as its return type is int<stdlib.h>, why include it?I suggest researching string literals, the functions available in <string.h> as well as format specifiers.
Also note, I am not checking the return of strncpy(), which is something you should be doing. That is left as an exercise for the reader.