char[1024] to c++ STL string

This is a discussion on char[1024] to c++ STL string within the C++ Programming forums, part of the General Programming Boards category; Hi, how to convert it? char buffer[1024]; fgets (buffer, sizeof(buffer), fp) // convert buffer to c++ STL string...

  1. #1
    dkt
    dkt is offline
    Registered User
    Join Date
    Sep 2001
    Posts
    18

    char[1024] to c++ STL string

    Hi,

    how to convert it?

    char buffer[1024];
    fgets (buffer, sizeof(buffer), fp)
    // convert buffer to c++ STL string

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    49
    1st: you should use ifstream instead of fp;
    2nd: you can convert like this:
    Code:
    string str(buffer);
    str is which you need.
    Hello, everyone.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 03:45 PM
  2. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 10:19 AM
  3. problems with overloaded '+' again
    By Brain Cell in forum C++ Programming
    Replies: 9
    Last Post: 04-14-2005, 06:13 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21