Saturday, 7 September 2013

Why this Ansi C program does not give result?

Why this Ansi C program does not give result?

I am using ubuntu 12.04 lts with gcc. This ANSI C code has no error or
warning when it is compiled, but when i try to execute a.out file, some
junk values appear. Can anyone tell me, what is wrong with this program?
#include <stdio.h>
int get_int(void);
int main (void)
{
int ret;
ret = get_int ;
putchar(ret);
printf("\n");
return 0 ;
}
int get_int(void)
{
int input;
char ch;
while ((scanf("%d", &input)) != 1)
{
while ((ch = getchar()) != '\n')
putchar(ch);
printf(" is not an integer.\nPlease enter an ");
printf("integer value, such as 25, -178, or 3: ");
}
return input;
}

No comments:

Post a Comment