Skip to content

Instantly share code, notes, and snippets.

@briandk
Created October 19, 2011 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandk/1299586 to your computer and use it in GitHub Desktop.
Save briandk/1299586 to your computer and use it in GitHub Desktop.
Why won't my strings work?
#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