Absolute beginner

I am an absolute begginer to programming and I am taking a self help course at home. I'm using the book teach yourself c++ in 21 days < ha ha i'm at day 10 and it has already been a month.> So far i'm comfortable with my compiler and can code from the book easily. I am having problems with the creation of my own freestyle programs.

To start: I am writing a program that will print an output to the console screen a number of times when asked. I want the program to take inputtted characters and then print out the number of times requested. So far I can do this from the main body but not from keyboard input. What am I missing?

Please help.

Here is the code:
// Priactice program.cpp : Defines the entry point for the console application.
//This is a practice program

I figured out what I was doing wrong. But there are some details that I need to have cleared up. For instance, what if I needed to include spaces between characters?

I fixed this simple program by introducing <char> and initialized it to <Nam> and gave those parameters an argument set to [100] and it worked!!!! but when I introduced spaces in my name the program just falls through.

I need further insight. Please help!!!

Here is the new code;

// Priactice program.cpp : Defines the entry point for the console application.
//This is a practice program

I appreciate the help and insight that you provided for me and I'm taking it all into consideration. This is my first attempt at programming so I don't want to make any comments because I need your experience to guide me but, I do want to keep the book because it is giving me the <fundamentals> that I need.

Your code is a lot more efficent than mine. the fully written for Statement cleaned up a lot of whitespace and the system pause worked perfectly. There were some minor tweaks I made to make the code work and it performed perfectly!!!!

Thank you!!!!

This is the beginning for me in this communtiy. Please work with me as I grow, I know that I can surely be a benefit here.

Since you commented this out, the library <limits> has no use, so feel free to leave that out. system("pause") ; is a more user friendly approach to pausing at the end of a program, but beware, it is extremely inefficient and has massive security holes in larger programs. Feel free to use it in early programs, but as you progress try and detach yourself from using it.

I would like to express my thanks for your expertise and adivse. In my studies I will be moving into inheritence and arrays in the coming few days < or weeks > I am taking my time to fully digest this language before looking into more advanced books on c++ to develop my own programming style.

I ran in to the same problem you described, where cin >> userName terminated at the first space and disrupt the program flow.

Following the book's examples, I used getline(cin, userName); to capture the full string. Others can correct me if I'm wrong, but that should be a more robust solution using the standard string library. Should help avoid potential crashes if your user enters a name longer than 100 characters.

A for loop probably would have been a better implementation. Will keep that in mind for next time. Here's to learning more C++!