Trying to assign a user-input string to a Char array.

SOLVED

Hello, this is my first post on this subreddit, but I am having a lot of trouble with this program I am just doing for fun.

I had the idea of doing a program where each letter of a string flips around after remembering that the word "Wizard" can have each letter flipped alphabetically, and that final result is "draziW".

I can get this to work no problem if I just initialize the char array like so:

char str1[] = "wizard";

But, I am wondering how exactly I could get it to where str1 could be set to a user input string.

***I KNOW THIS CODE WILL NOT COMPILE RIGHT, BUT YOU GET THE IDEA: ***

string word; char str1[] = word;

Thank you so much for any help you can provide. Here is a link to my working code: http://puu.sh/kd2Rq/1e72a6449b.png

Posted Sep 16, 2015, 7:10 AM UTC

16
Loading comments…