Hey, I'm not too sure what the problem is here, I have never had trouble using fscanf before. The following shows the code I use to check the file, and the result.

while( true ) {
		int vals_read = fscanf(fileHandle,"%[^;];%s",&name,&pass);
		if( vals_read == 2 ) {
			// process the line
			table.Insert(pass,name);
		} else if( feof( fileHandle ) )
			break;
	}

This is my latest attempt. I have also tried "%s%s","%s %s","%[^;]%s","%[^ ] %s". It does not read the file correctly at all. My file consists of 1 line so far:
George;TEST

While debugging, I find the pass variable is a single "T" and the name has nothing in it.

Also while debugging, if I check the status of fileHandle(my file) it has this "value" : fileHandle = 0x1035e4f8 {_ptr=0x003d7390 "George;TESTÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ...

also here: http://www.cplusplus.com/forum/beginner/41304/

Recommended Answers

All 4 Replies

How name and pass are declared?

Just above as std::string name = ""; std::string pass = "";

You can't send std.string to fscanf. It expects a C-style character array.

commented: thanks +1

Oh god. I didn't read info on fscanf too well. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.