C++ is shit and I have never used it. But certainly it should be able to handle a vector of strings? Just make a vector of strings and read them one at a time as strings, then append them to your vector.
23,000 lines.
TF? I thought /prog/ told me that SEPPLES was most powful and perfect, I cons up millions of lines from files in shit Lisps to make the GC shit its pantsu, IHBT.
ifstream myFile; //Set vector elements to lines from text file
myFile.open("ex100926.txt"); //Open txt file
while (getline(myFile, line))
{
lines.push_back(line);
}
//Close txt file
myFile.close(); //Close txt file
cout<<lines.at(0)<<endl;
This gives me a vector error, because apparently the lines from the text file aren't being read or put into the vector?
I basically have a 100% identical code for another program, which places each string into an array rather than a vector, and that one works 100% fine. (and yes, the file is there and has text in it)
"stdafx.h"
Visual bullshit detected, did you place your textfile in the right place /debug folder or w/e,
also some IDEs (fuck you netbeans!) need the file in the project folder when ran through the debugger,
check the is_open()
Well what do you want, OP, for us to teach you how to debug? The one good thing that can be said about Visual Studio is that it has excellent debugging features. Set some breakpoints, catch some exceptions, figure out what the fuck is going wrong.
>>17
Well, then I guess you just have to give up. The program should work but doesn't, so there is a bug in the universe that is preventing it from working. You might get into Wired Magazine for discovering this.
How long did you wait for something to such up since it's Microsoft Visual Retard (prolly auto'd to Managed C++ too)
it might just be fuck slow to parse 23k lines, did you see the Pause message show up?
(srsly my cygwined gcc is faster on windows than the native Microsoft stuff, go MS!)
getline returns an istream &
why doesn't this code loop forever?
Name:
Anonymous2011-12-15 21:14
>>19
The pause message shows up almost instantaneously. (Text file line parsing is extremely fast regardless, in comparison to something like a URL download to file)
>>22
Because it only loops until there aren't any more lines to read from the text file
Name:
Anonymous2011-12-15 21:35
>>23
No, no, no. The return type is an istream reference, specifically a reference to the istream that the input was taken from. This reference should always be valid. Therefore, the loop should loop forever.... Maybe it's converted to a void *?...
Anyway. I chopped off the first line (MS specific stuff) and compiled with the text file set as the source file and it worked fine under Cygwin.
>>24 This reference should always be valid. Therefore, the loop should loop forever.... Maybe it's converted to a void *?
Yes. ifstream defines a ` void * operator` which returns a non-null if the file is readable or null if the file is not open or there are no more data or an error occurred.
>>17 Except therein lies the problem. As far as the debugger or anyone is concerned, this program SHOULD work.
Are you retarded? Do you understand what a "debugger" is? You don't ask the debugger what it is concerned about, you run a program in the debugger and see why it doesn't work.
Or you can add `printf("%d\n", myFile.is_open());` and see that you failed to put the file in the same directory as your program, you fucking retarded moron.
>>27
debugger you so tsundere, you never tell me what are you concerned about,
BTW: I compiled this bull in M$ Visual Niggerudio, made a 180k lines of 'fagstorm' 27 times per line, and it fucking worked.
Also if the vector read nothing the .at(0) at end should throw shit at him.
So wtf?
OP post 1st line of the file
#Software: Microsoft Internet Information Services 6.0
#Version: 1.0
#Date: 2010-09-27 00:00:00
Name:
Anonymous2011-12-16 18:36
23000 lines
Assuming 80 characters per line average
23000 * 80 = 1840000 bytes
Adding on a few extra bytes for the other shit in the vector...
Your computer has more than 2 Megabytes of RAM, right OP? Because if it has more than 2 Megabytes of RAM, you should be fine making a vector of 23000 strings. +
I lost members of my family in auschwitz I don't find that funny at all would you still find it funny if members of your family had been murdered in a death camp by the Nazis I can't see there is nothing remotely about 6.000.000 people being systematically and deliberately murdered