CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Mar 2007
    Posts
    9

    Reading form file ANSI C function help

    Hy everybody!

    I am trying to make a function that reads data from a text file , from a specific position :
    data looks like this :
    04000040MAAS SECURITE SOCIETE DE SECURITE PRIVE
    04000040MMARTIN ELSA RAPHAELLE
    on two lines . I need lets say the names I have to go to a start position that I know my data is and get it ( I know the length)
    My code is for the function :
    void Get_Name(int start_pozition,int item_lenght, FILE *Nourea_file)/* Funtion who returns an item on a certain pozition on the imput file*/
    {
    char *read_Buffer;

    char *c[100];
    int j=1;
    fgets(read_Buffer,1000,Nourea_file);
    while(!feof(Nourea_file)){
    fgets(read_Buffer, start_pozition,Nourea_file);
    c[j]=(char *)malloc(item_lenght*sizeof(char));
    strcpy(c[j],fgets(read_Buffer, item_lenght,Nourea_file));
    j++;
    fgets(read_Buffer, 1000,Nourea_file);
    }
    puts(c[1]);gectch() // for test purpose
    }


    When I try to increment the pointer array seams empty.
    Please help I will appreciate it very much .
    Thanks for you're answers !
    Last edited by Valy18; October 26th, 2008 at 01:33 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured