Created
October 30, 2018 01:37
-
-
Save dj-amadeous/165487ccc0bcd3f60ede6f4f5ea34e93 to your computer and use it in GitHub Desktop.
example of using fgets to get integer input to avoid scanf
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
int getSize(){ | |
int numEl; | |
char term[3]; | |
printf("Enter size of Array:"); | |
fgets(term, 6, stdin); | |
numEl = strtol(term, NULL, 10); | |
return numEl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment