Created
October 19, 2011 20:37
-
-
Save briandk/1299586 to your computer and use it in GitHub Desktop.
Why won't my strings work?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void blank_string (char *s) { | |
int i = 0; | |
for (i = 0; i < 10; i = i + 1) { | |
*(s + i) = "5"; | |
} | |
*(s + 10) = "\0"; | |
} | |
int main (int argc, char const *argv[]) { | |
char myarray[11]; | |
blank_string(myarray); | |
printf("%s", myarray); | |
return(0); | |
} | |
/* Output | |
scratchpad.c: In function ‘blank_string’: | |
scratchpad.c:7: warning: assignment makes integer from pointer without a cast | |
scratchpad.c:9: warning: assignment makes integer from pointer without a cast | |
$$$$$$$$$$) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment