how to assign a value of space in c++
In c++, ascii characters has a default value. Like ! has a value of 33,
"," has also a value of 44 and so on.
inside my text file "hehe.txt" is. ;!,.
#include <iostream>
#include <fstream>
int main(){
std::ifstream file("hehe.txt");
if(file.eof())return 0;
char ascii;
while (file>>ascii) {
std::cout<<(int)ascii << " ";
}
system("pause"
}
Output is 59 33 44 46.
What if i have space between the characters? How may I give it a value?
Lets say the space has a value of 32. Suppose I added space after the last
character ;!,. the output must be 59 33 44 46. Hope someone could give me
an idea how to do it.
No comments:
Post a Comment