Thread: Inputting-Outputting specific areas of a file

  1. #16
    Registered User
    Join Date
    Apr 2008
    Posts
    122
    Code:
    for(int i = 0; i < MaxPages; i++)
      {
          getline(input,address);
          if(isAGet(address)==true)
          {
              extractTheRequest(address);
              extractLocator(address);
              locators[i] = extractLocator(address);
              cout << locators[i] << endl;
          }
      }
    Aparently the bool function of isAGet is not evaluating to true for some reason. This is really starting to get to me... I've tried so many variations and am having the toughest time with this.

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    What is the return type of isAGet()? If its not bool, it might be returning some other value as true instead.

  3. #18
    Registered User
    Join Date
    Apr 2008
    Posts
    122
    When I have the if statement set to false it works. Look back at the first page to see the bool function isAGet.

    Okay, I now have the thing working correctly. I am now moving on to counting how many times a page is shown. Here is the working function!!

    Code:
      getline(input, address);
      for(int i = 0; i < MaxPages; i++)
      {
          if(isAGet(address) == false)
          {
              extractLocator(extractTheRequest(address));
              cout << extractLocator(extractTheRequest(address)) << endl;
              locators[i] = extractLocator(extractTheRequest(address));
              getline(input, address);
          }
      }

  4. #19
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Let's pay a little bit of attention, shall we?
    Code:
    for(int i = 0; i < MaxPages; i++)
      {
          getline(input,address);
          if(isAGet(address)==true) //this can't be true because address isn't a get until we extract the request
          {
              string request = extractTheRequest(address);
              //extractLocator(address); why do this line twice?
              locators[i] = extractLocator(request);
              cout << locators[i] << endl;
          }
      }

  5. #20
    Registered User
    Join Date
    Apr 2008
    Posts
    122
    or what I could do, which is what I did, is this:

    Code:
      getline(input, address);
      for(int i = 0; i < MaxPages; i++)
      {
          if(isAGet(extractTheRequest(address)) == true)
          {
              extractLocator(extractTheRequest(address));
              cout << extractLocator(extractTheRequest(address)) << endl;
              locators[i] = extractLocator(extractTheRequest(address));
              getline(input, address);
          }
      }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Looping when outputting to a file
    By nizbit in forum C Programming
    Replies: 4
    Last Post: 03-05-2005, 10:26 AM