for example
#include
#include
#include
char substr[10][20];
int main() {
substr[0] = \"abc\";
pr
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
#include
#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, why include it?I suggest researching string literals, the functions available in 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.