-
simple question
I have a really simple problem.
I forgot how to assign a message to a string with a counter.
I thought it was something like this:
Code:
startunit[i] = "mm";
but it does not work
Any help tonight would be great. I have a program due in 12 hrs, and this is the main problem right now.
thanks.
-
Code:
strcpy(startunit[i], "mm");
-
When I tried
Code:
strcpy(startunit[i], "mm");
I got the error
Code:
83 C:\Dev-Cpp\final.c [Warning] passing arg 1 of `strcpy' makes pointer from integer without a cast
I defined the string as
Code:
char startunit [5];
-
strcpy(startunit,"mm");
or
strcpy(&startunit[3],"mm");
The second one will probably create garbage in front of the "mm"
-
or this
Code:
startunit[i]='m'
startunit[i+1]='m'
Of course i must be incrimented by at least 2 eah iteration otherwise you would be overwriting the second char.