I
Ian Arnold
Alright, so I know that you can use char pointers to store strings, and
I'm trying to make a very simple program to see how it all works that
will have the user enter 5 characters, then the computer will show
those five characters back to the user. So far I have:
#include <iostream.h>
int main()
{
char* buffer = " "; //Five spaces
char in;
char out;
while(in = *buffer++)
{
cin >> in;
}
while(out = *buffer++)
{
cout << out;
}
return 0;
}
This program works how it is supposed to until it gets to the
outputing; nothing happens. It gets the five characters, then ends.
Please help me make this work, and if possible I want it to be based
off of using the char*, and not an array or just five char variables.
Thank you!
I'm trying to make a very simple program to see how it all works that
will have the user enter 5 characters, then the computer will show
those five characters back to the user. So far I have:
#include <iostream.h>
int main()
{
char* buffer = " "; //Five spaces
char in;
char out;
while(in = *buffer++)
{
cin >> in;
}
while(out = *buffer++)
{
cout << out;
}
return 0;
}
This program works how it is supposed to until it gets to the
outputing; nothing happens. It gets the five characters, then ends.
Please help me make this work, and if possible I want it to be based
off of using the char*, and not an array or just five char variables.
Thank you!