"assignment makes integer from pointer without a cast " warning in c
Posted
by mekasperasky
on Stack Overflow
See other posts from Stack Overflow
or by mekasperasky
Published on 2010-04-18T16:47:33Z
Indexed on
2010/04/18
16:53 UTC
Read the original article
Hit count: 200
Filed under:
c
#include<stdio.h>
/* this is a lexer which recognizes constants , variables ,symbols, identifiers , functions , comments and also header files . It stores the lexemes in 3 different files . One file contains all the headers and the comments . Another file will contain all the variables , another will contain all the symbols. */
int main()
{
int i=0,j;
char a,b[20],c[30];
FILE *fp1,*fp2;
c[0]='"if";
c[1]="then";
c[2]="else";
c[3]="switch";
c[4]="printf";
c[5]="scanf";
c[6]="NULL";
c[7]="int";
c[8]="char";
c[9]="float";
c[10]="long";
c[11]="double";
c[12]="char";
c[13]="const";
c[14]="continue";
c[15]="break";
c[16]="for";
c[17]="size of";
c[18]="register";
c[19]="short";
c[20]="auto";
c[21]="while";
c[22]="do";
c[23]="case";
fp1=fopen("source.txt","r"); //the source file is opened in read only mode which will passed through the lexer
fp2=fopen("lext.txt","w");
//now lets remove all the white spaces and store the rest of the words in a file
if(fp1==NULL)
{
perror("failed to open source.txt");
//return EXIT_FAILURE;
}
i=0;
while(!feof(fp1))
{
a=fgetc(fp1);
if(a!=' ')
{
b[i]=a;
}
else
{
for (j=0;j<23;j++)
{
if(c[j]==b)
{
fprintf(fp2, "%.20s\n", c[j]);
continue ;
}
b[i]='\0';
fprintf(fp2, "%.20s\n", b);
i=0;
continue;
}
//else if
//{
i=i+1;
/*Switch(a)
{
case EOF :return eof;
case '+':sym=sym+1;
case '-':sym=sym+1;
case '*':sym=sym+1;
case '/':sym=sym+1;
case '%':sym=sym+1;
case '
*/
}
fclose(fp1);
fclose(fp2);
return 0;
}
This is my c code for lexical analysis .. its giving warnings and also not writing anything into the lext file ..
© Stack Overflow or respective owner