I am unable to find out if the ternary operator is present or not through following code.. Plz help.
#include <stdio.h>
#include <ctype.h>
#include <string.h>
void one();
int main()
{
FILE *fp;
fp=fopen("C:/Users/HP/Documents/NetBeansProjects/CD2/1.txt","r");
char c;
void one()
{
char c;
while((c=fgetc(fp)!=EOF))
{
if(c==':')
{
printf("\nThe ternary operator present");
return;
}
}
}
while((c=fgetc(fp))!=EOF)
{
printf("\n-->%c",c);
if(c=='?')
{
one();
}
}
return 0;
}
I want to know why this code doesn't work and say if the ternary operator is present or not in file 1.txt
The output shows all characters till '?' if we print them, but why it's not finding for a colon ':' ?