That's it... I'm downloading Dev-C++
That's it... I'm downloading Dev-C++
Thank you lol
Knowing my luck it'll be some msyterious dev bug and ill have to change compiler
Code:#include <iostream.h> int main () { char c = 'ÿ'; cout.flags(ios::hex | ios::showbase); cout << int(c); return 0; }
Argh recommend any good win compilers?
Yes, Visual C++
The code works now right? I'm such an idiot!
dude ure the gr8est
No, I told you... I'm an idiot!
last thing how do i check if file opens correctly?
hmm, well you first have to open the file. Then do this:
Or it could be file.error or something; I'm not sure. But if you're just checking if the file didn't exist, you have to call 2 error checker thinger functions (if one says there's an error, you have to check the other one; if the other one says there's no error, it means that it's a small error such as file not found. Otherwise, you're in deep doodoo! )Code:if(file.fail()) //whatever you do if it fails
Actually, I might be wrong... maybe you can directly check the error flags, but I'm too lazy to figure it out myself; you'll have to ask bmj
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
If the .open() fails, the return is NULL, so you can do this:
Code:#include <fstream.h> int main () { ifstream ifile; ifile.open("NotThere.txt", ios::in); if (!ifile) { cout <<"Error" <<endl; return 1; } ifile.close(); return 0; }
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Oh right, lol how could I forget the obvious?
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
drugs?Originally posted by Hunter2
Oh right, lol how could I forget the obvious?
Thats the code i would like to use but it doesnt work.Code:switch(int(buf)) { case 0x8A: file1<<"A"; break; default: file1<<int(buf); break; }
The program should:
Check to see what the read char was if and save it as diff char depending of what was read.
i really dont wanna make a varirable containing all 50odd cases i have.
that outputs i to the screen in hexadecimal. nice and clean. you nead iostream... I don't think it matters if you have the .h or notCode:cout << hex < i
What about binary or octal?
cout << binary << 'h'
cout << octal << 'G'
???
~Inquirer
Compilers:
GCC on Red Hat 8.1 (Primary)
GCC on Mac OS X 10.2.4 (Secondary)
Others:
MinGW on XP