Hello Guys!
I am suffering with xcode compiler while i am compiling the below code.
At first the problem was on getch( ) and ungetch ( ) , then I have been advised to use getc/fgetc
Now the error massage is: error: expected identifier or '(' before '{' token
Thank you in advance for your help.
Senan
#include <ctype.h>
#include <stdio.h>
{
unsigned int c, sign;
while (isspace(c=getc())); //test whether c is a character of white space
if(!isdigit(c) && c != EOF && c != '+' && c != '-') //if c is not a digit and it is not equal End Of File (valued -1) and it is not + and it is not -
{
ungetc(c); //push a character back into an input stream
return 0;
}
sign = (c == '-') ? -1 : 1; //if c equal - so it is -1 else it is 1
//if c equal - so it is -1 else it is 1
if (c == '+' || c == '-') // if c equal + or c equal -
c = getc(); //single character is get or read thru getch
if (!isdigit(c)) { ungetc(c);}
else
{
*pn =0;
for (; isdigit(c) ; c= getc())
*pn=10 * *pn + (c - '0');
*pn *= sign; //*pn = *pn * sign
if(c != EOF)//if c equal end of file
ungetc(c); //push a character back into an input stream
}
return c;
}
int main (void)
{
int a; int g;
a=getc(&g);
printf("a");
printf("g");
return 0;
}