Last active
June 13, 2016 00:41
-
-
Save redgosho/20365f181ea7a1f826d044bc82a40c50 to your computer and use it in GitHub Desktop.
getnum_int
This file contains hidden or 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> | |
#include <stdlib.h> | |
double getnum_int()//入力関数 | |
{ | |
int i; | |
int num,cheak; | |
cheak = 1; | |
i = 0; | |
num = 0; | |
char getnum[200], | |
c; | |
printf("整数を入力してください。\n>>"); | |
while(cheak == 1){ | |
cheak = 0; | |
i = 0; | |
while(i < 200 && (c = getchar()) != '\n'){ | |
getnum[i] = c; | |
i++; | |
if(c == '.'){ | |
printf("整数を入力してください。\n>>"); | |
for (int z = 0; z < 200; z++) | |
{ | |
getnum[z] = 0; | |
} | |
cheak = 1; | |
} | |
} | |
} | |
while(i == 201){ | |
i++; | |
printf("%c\n",getnum[i]); | |
} | |
getnum[i] = 0; | |
num = atoi(getnum); | |
printf("%dが入力されました。\n",num); | |
return num; | |
} | |
int main(){ | |
getnum_int(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment