#include <stdio.h>
int add3main(int x, int y, int z)
{
return x+y+z;
}
void add2to3()
{
int (*function_pointer) (int, int) ;
function_pointer = &add3;
i = function_pointer(2,3);
printf(" ans = %d \n",i);
}
argc, char *argv[])
{
FILE *info = fopen( "widget.txt", "r");
int a,b,c;
if(info == NULL)
{
perror("Could not open file");
return 0;
}
if(fscanf(info,"%i %i %i", &a, &b, &c)!=3)
{
fprintf(stderr, "Expected but did not find three integers \n");
fclose(info);
return 0;
}
else
{
printf("abc is %i%i%i\n",a,b,c);
}
int j=3;
if(fsetpos(info, &j)!=0)
{
perror("fsetpos failed");
fclose(info);
return 0;
}
if(fscanf(info,"%i %i %i", &a, &b, &c)!=3)
{
fprintf(stderr, "Expected but did not find %i %i %i \n");
}
else
{
printf("abc is %i%i%i \n",a,b,c);
}
fclose(info);
return 0;
}
}
|