EOD4

Posts 1–6 of 6 · Page 1 of 1
Nothing to see here.
This thread never happened.
Nope..
i've seen this before on this site and pointed it out to you yesterday too
that FOR loop is wrong; The way your middle argument is specified it's basically the same as
Code:
int i = 0;
while(files) //!=null
{
...
i++;
}
Which unless you move that pointer inside the for loop is an infinite loop. So you go out of bounds and start reading garbage data , which at one point or another will most likely contain a comma which kicks you out with the exception you throw.

Also Throwing an exception is a little heavy just for passing in more arguments than what you're looking for.. a simple 'if' would be better imo

Last; lot of work for trying to do something the system already provides for you, here's a crappy implementation:
Code:
        char* file[2];
	char* files = new char[50];
	cout << "Enter: File1,File2\n";
	cin >> files;

	int p = 0;
	char* pFile = strtok(files,",");
	while(pFile != NULL && p < 2)
	{
		file[p++] = pFile;
		pFile= strtok(NULL,",");
	}
        //say something hereif more than 2 arguments (pfile != null) and return;
        // of course call 'delete files' before exiting
Omg. Im a fkin idiot. -__- that's so simple. how could I have missed that. Thanks BA. Sorry for some reason I couldn't understand what you said yesterday. Now it seems so obvious.

And ur code looks so much more sexy then mine >_>.
Quote Originally Posted by why06jz View Post
This thread never happened.
XD ROFLMAO
Let's just keep this little screw up between you and me
Code:
                char* file[2];
                file[0] = &files[0];
		char* tok = strchr(files,(int)',');
		file[1] = tok+1;
		*tok = '\0';
I'll just leave this here since you know it's sexy hahah
Posts 1–6 of 6 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

Talk with us