View Single Post
  #2 (permalink)  
Old July 23rd, 2008, 01:42 AM
elvisfeverr elvisfeverr is offline
Authorized User
 
Join Date: Jan 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well cin>> just ignores spaces you need to use getline() to read a string that contains any whitespace character but there is another problem with your code : char names[index][20] = char names[0][20] here you create a string array with 0 rows and 20 columns and when you create an array like this staticaly you can not change or reallocate by index++ you will then try to reach a memory location that is outside boundaries and start to write a memory location outside of your program and this is very dangerous..since the user can add as many names as he wants cause you do not check the limits you have to allocate memory dynamically or first get the number of total names from user then check the limits.hope this helps.

Reply With Quote