Skip to content

Instantly share code, notes, and snippets.

@redgosho
Last active June 13, 2016 00:41
Show Gist options
  • Save redgosho/20365f181ea7a1f826d044bc82a40c50 to your computer and use it in GitHub Desktop.
Save redgosho/20365f181ea7a1f826d044bc82a40c50 to your computer and use it in GitHub Desktop.
getnum_int
#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