i know gow to get characters from a file using in_stream.get(next). is there a way to get characters from a user instead of from a file and how would i do this.
i know gow to get characters from a file using in_stream.get(next). is there a way to get characters from a user instead of from a file and how would i do this.
#include <iostream>
main(void)
{
int x;
int y;
cout<<"please enter something x"<<endl;
cin>>x;
cout<<x<<":::blab"<<endl;
cin.get();
cout<<"please enter something y"<<endl;
y = cin.get();
cout<<y<<":::blab"<<endl;
}
i dont understand how that would work......wouldnt it get an integer instead of a character. i want to be able to have the user enter a sentence and access that sentence one character at a time.
#include <iostream>
main(void)
{
char xp;
cout<<"please enter something xp"<<endl;
cin.get(xp);
cout<<xp<<":::blab"<<endl;
}
ok that didnt work.......what was that last ::blab line?
it worked
If you want a string then use getline functin and make it char *
Thanks
i want the user to be able to enter a string but for the program to access that string one character at a time. the exact same thing as getting characters from a file using in_stream.get(next) except getting them from the user. i tried what yous ent in my program but it didnt work. what was that last ::blab line doing?
//just kiding!Code:#include <iostream> using namespace std; int main() { char bob[256]; cout << "enter the true name of god!" << endl; cin >> bob; for (int i = 0; bob[i] != 0; i++) cout << bob[i]; cout << endl<< "how dare you call his name!"<<endl; }
blab stuff means blablabla... its nothing!
Luigi
// I use Xcode 1.1 && CodeWarrior 8.3
// When on Mac Os X 10.3.2
// I use Microsoft Visual C++ 6.0
// When on windows XP