Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Skiping through a text file?

Name: Anonymous 2011-02-28 19:56

I have a text file filled with words (one per line). When I tried this C++ function out, it worked once and then every time after it just returns nothing. What gives?

for (i=0;i<(rand()%10);i++){
              if (fin.eof()==true)
                 fin.seekg(ios::beg);
              fin.ignore(256,'/n');
          }
         
fin.getline(word,30);
         
          //TESTING
          cout<<"Found random word: "<<word<<endl;



inb4 newprogrammingfagcan'tprogram etc.

Name: Anonymous 2011-02-28 19:59

Rand generates negative numbers as well as positive.

Name: Anonymous 2011-02-28 20:03

If it doesn't find the word, your program won't do anything.

Name: Anonymous 2011-02-28 20:06

2: I thought rand() was unsigned and only generated positive integers?

3: It's not looking for a specific word, just A word. I don't understand why it's not returning anything, because the only stuff in the file is words, /n and EOF.

Name: Anonymous 2011-02-28 20:18

Oh FFS I figured it out. \n not /n. DUH. :(

Name: Anonymous 2011-02-28 21:29

C++ now you have 3-“Ó ÅþNÓ‹²Ä[?

şͤ̀̊͋҉̨̬̥͖͈̠ȇ̴̢̟̭͕̝̲̦̙͆g̷̢ͥ͗̅̄ͨ҉̗̪̼̻͇̳̰m̢̛͚̗͎̻͙̙͐͐͐̉͊e̢͎̫̮̽̈́͐̑͝ͅņ̧̟̳̙̬̋ͦ͂͗͌̽͊ͤͩ̀t͙ͦ̇̋ͧ͝͠a̵̺̮̞̅̓̿̊͋̚̕t̩̣̹͖̺͒̏̋ͦi̻̗̥̩͓̐́̓ͫ̏ͭ̉̓̾͟͝o̧̡̱͍͕̜̙͙͚̻ͯͫͪ̌̔̆̕n̢̠̫̻̺͖͙̩̋͆͑̄̈͂ ̵̻̰͕̉̾͒̉͑f̲̝̟̤͎ͦ̏̓ͨͨͭ͡a͔͖ͯͬ̿̄ͤ͊ü̴̙̣͔̙̊̔́͟l̴̮͎̰̺̜̦̗̱̍ṭ̨̡͕̉ͦ


̰̰͇̤̱̟̄̂̓́͟͝c̫̝͚͙͚̲͆̐͢o̜̥̾̈́̅͑͐̽̉̂̚͟r̡̬̜̗̺͇̜ͭ̉̍̑͜ê̶͍̮̈̆̑͒̾̈́ ̬̻͓̣͎͙̠̥̈́̋ͦ̓͐̿ͨd̴̘̭͑͐ͨ͛̂́͡u̴̧̮͇̥͈̖ͪͭ͐̔m̈ͦ̅̐̀͏̛҉̯̺͕͇̩p͓̭̬͒͒ͥ̿̿e̙̻̼̭̬͈ͮ͒̒͑́͗̄͘d͕̫̣̘͒ͩ̈́ͩ̀͠

Don't change these.
Name: Email:
Entire Thread Thread List