Skip to content

Instantly share code, notes, and snippets.

@joyeecheung
Created October 14, 2014 06:31
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 joyeecheung/1362352a14c0304d04f8 to your computer and use it in GitHub Desktop.
Save joyeecheung/1362352a14c0304d04f8 to your computer and use it in GitHub Desktop.
read a string unitl a newline character is entered
#include <stdio.h>
int main(int argc, char *argv[]) {
char msg[100];
char *in = "%99[^\n]%*c";
scanf(in, msg);
printf("%s\n", msg);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment