   Problem with fscanf
  I'm doing some simple file reading (actually recursive file reading), anyway, when  I was using ifstream to open a file I would get an empty handle returned (not too sure why even though the file exist). I switched to a FILE* and that works just fine. My question is, is there another version of fscanf that ignores white space (much like the c++ getline function) ??[Edited by - jon723 on December 13, 2005 12:55:55 PM]
  Ok, first off, I'd try to figure out why the fstream is failing.  Are you trying to open the file for writing when it's read only, etc...  But if memory serves, you can just use something like fread and use '\n' as the delimiter assuming you are trying to get an entire line of text.   ;  Yea, i've been debugging the fstream thing to no avail. Looking through the doc's on the fread function, the only parameters I see have to to do with buffer storage, the size, numbers of items to read, and a file stream. Where exactly would i tell it to stop at a newline.   ;  The question is not stupid, but the topic is. Use a more descriptive one. Post the code using fstream which fails and we can take a look at it (post only relevant parts).   ;  You can use the getline() function with ifstream...i.e.ifstream inFile;inFile.open("DATAFILE.DAT",  ios::in);getline(inFile, newVariable, '#');  // # delimiterThat will ignore whitespace up to the delimiter...   ;  Well, I have the following code which has worked several times before for opening a file:ifstream htmlfile;htmlfile.open(temp);if(!htmlfile) htmlfile.close(); return;'temp' in this case would be somethine like "c:/test/htmlfiles/stuff.htm". For some strange reason it always returns as if the file doesnt exist. Does anyone know under what circumstances a call to open would fail for a file that "does" exist??   ;  Take a very close look. Of course it always returns because you tell it to:ifstream htmlfile;htmlfile.open(temp);if(!htmlfile) htmlfile.close(); return;You realize, that the return statement isn't part of the if, do you? C++ doesn't care that the return is in the same line with the if. Only the next (htmlfile.close();) statement ist executed depending on the if without curly brackets.What you want is this:ifstream htmlfile;htmlfile.open(temp);if(!htmlfile){    htmlfile.close();    return;};  Not to mention that the htmlfile.close(); is completely redundant anyway.  The ifstream destructor will automatically close the file when it goes out of scope, which is kind-of part of the whole point of ifstream being a class in the first place.Enigma   