Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

help with C++ and char arrays

Status
Not open for further replies.

Guest
here is an example of the code I am trying
to use... as it goes through the interations
of populating the uNameCpy, the data in the
original variable gets screwed up...

[tt]
#include <iostream.h> // cout/cin, etc
#include <stdlib.h> // for conversion functions
#include <string> // include for C++ standard string class
#include <conio.h> // for video stuff (like clrscr)
int main()
{
char uName[30], uNameCpy[30];
cin >> uName;
//charcrlf;
//getch();
//crlf = cin.get();
cnt=1;
cntCpy=0;
do
{
uName[cnt]=uNameCpy[cnt];
cnt++;
}
while (cnt < 5);
cout << &quot;You Entered: &quot; << uName << &quot;\n&quot;;
return 0;
}
[/tt]
...could anyone help me understand why this
isnt working as I thought it should?
thankx,
myAvatar
 
Replies continue below

Recommended for you

nevermind, I cant believe I did that... switched the ^&%^% variables around... sorry all, plz delete this post :)
 
Actually , i am not getting your code in understand. What exactly. in while loop you have to copy one by one all the contents in uNameCpy. Through that you can easily get the result. Or you can reverse the string also.
 
Status
Not open for further replies.
Back
Top