Results 1 to 3 of 3

Thread: Read Line Text

  1. #1

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    How do i read a line from a text file in a Win32 app. If i use this in a non dos app i get errors:
    Code:
    char buffer[81];
    FILE *in_file,*fopen();
    char *fgets(); 
    if((in_file = fopen ( "c:\\bootlog.txt","r"))!= NULL )
    { 
    fgets(buffer,81,in_file);
    }
    Errors:
    : error C2660: 'fopen' : function does not take 2 parameters
    : error C2660: 'fgets' : function does not take 3 parameters
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  2. #2

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I managed to get this to work
    Code:
    #include <fstream>
    #include <string>
    using namespace std;
    
    string str;
    ifstream i("c:\\bootlog.txt");
    getline(i,str);
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Why declare fopen() and fgets()? They're both in stdio.h, so why declare them with a different parameter list? I think if you leave the function declarations out the first bit of code should work.
    Harry.

    "From one thing, know ten thousand things."

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