Hi all,
I am trying to read a file in C.

The format of file is something like that :
-----------------------------
<From: sender@hotmail.com>
Hellooooooooo.
</from>
<From: george@gmail.com>
What am I doing?
nOwwwwwwwwwwwwww
</from>
----------------------------

I would like to read the file and extract some info like
number of emails , senders and messages from email.

I know that I have to open file then reading until eof
but I don't know regular expressions to do this.

Could you help me please ?

You can do this without reg expressions. Note: The code below was not compiled or tested.

#include <stdio.h>
#include <string.h>

int main()
{
   char line[255];
   char* ptr;
   FILE* fp = fopen("filename.txt","r");
   while( fgets(fp,line,sizeof(line) != NULL)
   {

      ptr = strstr(line,"<From: ");
      if( ptr != NULL)
      {
          // got it, so now do simething with it.

      }
   }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.