Created
June 29, 2012 14:17
-
-
Save thetekst/3018221 to your computer and use it in GitHub Desktop.
Input int, char, getchar()
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
//Input int | |
#include <stdio.h> | |
int main(int argc, char const *argv[]) | |
{ | |
int dec; | |
printf("Input: "); | |
scanf("%d", &dec); | |
printf("%d", dec); | |
return 0; | |
} | |
//Input char | |
#include <stdio.h> | |
int main(int argc, char const *argv[]) | |
{ | |
char str[20]; | |
printf("Input: "); | |
scanf("%s", &str); | |
printf("%s", str); | |
return 0; | |
} | |
//Input getchar() | |
#include <stdio.h> | |
int main(int argc, char const *argv[]) | |
{ | |
char c; | |
printf("Input: "); | |
while((c=getchar())!='\n') | |
{ | |
printf("%c",c); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment