Hello everybody!
I want to write a program in c that has to open a file (a c program) and count how many char or double declarations have been made in it, so as to calculate the amount of memory that char and double data types will occupy in memory. I started the program like this:
#include <stdio.h>
#include <stdlib.h>
main()
{
FILE *fp;
char c[20];
if ((fp=fopen("d:\\program.c","r"))==NULL)
{
printf("to arxeio den yparxei\n");
exit(0);
}
else {
printf("file opened successfully! Contents:\n");
while (fscanf(fp,"%s",c)!=EOF)
{
if (strcmp(c,"char")==0)
{
}
printf("String: %s \n",c);
}
}
system("pause");
}
but don't have any idea how to continue. Does anyone have an idea? Thank you in advance for reading my message...
vanalex