read ascii data from file

Hi,
I am search lot websites but still i am not solve the issue, I want to read the ascii values from a file, pls help me to solve that issue.
I believe it should be in beginners/general.
What format your file exactly? Method of reading depends on this
My file is text format with full ascii values like the below

÷£þ>z·kRD»D›+ o3§ðž–ã@ýbŸ7Ñp.v÷
,©˜’ÖÔÓ¤­,®­bn¤Ðìt“½.×ÃÒÂ;ví8+À‚ÜÑîò|¦Ä9ÐYHª§Áutù»ç£Ìì;öÑ?¨¢%ePŒ`¾~㔢Á“’gºØ7
G’·j\Yr,S¶–½tëj™?bÐŒ_öÄd


how to read that content of the file. Actually I am doing one password encryption program, that is why I want that, please help me, and tell me if its possible to read that content or not.

Thanks & regards
1
2
3
4
5
6
7
8
9
10
std::ifstream inp("yourFile");
char c;
inp >> c;//c now holds ascii value of first character. 
/*You can output integral value using:*/
std::cout << static_cast<unsigned>(c);
/*Or just use it as integral in calculations */
c +=2; //if c was 'a' it is now 'c'
std::cout << c; //Proof
if (c == 97) //Equals to c == 'a'
    //do something 
Last edited on
Topic archived. No new replies allowed.