Thread: an string array

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    23

    an string array

    is there a way to make an string array

    exp
    std::string test[255];

    Code:
    if((File = _findfirst( "image*.txt", &c_file )) == -1L)
         {
          printf("No %s files in current directory!\n");
         
    }
       else
       {
        // printf("%s\n", c_file.name);
    TextName = c_file.name;
    
          while( _findnext( File, &c_file ) == 0 )
          {
            // printf("%s\n", c_file.name);
             TextName = c_file.name;
             
          }
          _findclose(File);
       }
    What I need to acomplish is load a text file pull the data from that text file then go to the next file.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    What does the posted code have to do with the question? Yes, you can make an array of strings (you could also use a vector, which is usually preferred).

    Are you asking how to get the results from _findfirst and _findnext into the array? If so, use a vector and call push_back each time to push TextName on to the vector. Then later go through each value in the vector (use the size() method to get its size) and process the file.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer to array of string and Array of Pointer to String
    By vb.bajpai in forum C Programming
    Replies: 2
    Last Post: 06-15-2007, 06:04 AM
  2. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  3. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM
  4. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM