post #1 of 1
Thread Starter 
heh, solved my own problem. needed to declare the damn thing as x[10], derp





Hey guys, I'm having some trouble with a character array. I'm declaring it as

Code:
char x[9] = {'\\0'};
as I want the string to start off blank, then write in some characters to fill the array;

Code:
while (isalpha(input[i]))
          {
                x[i] = input[i];
                i++;
          }

However, I'm having problems with the array staying within the desired 9 char spaces; ie when printing I'll get something like

Code:
x = [desired output][random jibberish]
Any idea why? I thought I took every precaution to limit the length of the array, but for some reason it just doesn't want to be limited to 9 character spaces.. all help would be greatly appreciated.
Edited by Haleiwa Salt - 2/22/11 at 11:31pm
Late 2010
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7-950 3.06GHz (OC to 3.8GHz stable) ASUS Sabertooth X58 LGA 1366 EVGA GeForce GTX 460 1GB 12GB (6x2GB) G.SKILL DDR3 1600 (PC3 12800) 
Hard DriveOptical DriveOSMonitor
1TB Hitachi Deskstar 7200 RPM 32MB Cache HP dvd1260 Windows 7 23" Dell U2311H 
PowerCase
Corsair 750TX 750W Cooler Master HAF 932 Full Tower 
  hide details  
Reply
Late 2010
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7-950 3.06GHz (OC to 3.8GHz stable) ASUS Sabertooth X58 LGA 1366 EVGA GeForce GTX 460 1GB 12GB (6x2GB) G.SKILL DDR3 1600 (PC3 12800) 
Hard DriveOptical DriveOSMonitor
1TB Hitachi Deskstar 7200 RPM 32MB Cache HP dvd1260 Windows 7 23" Dell U2311H 
PowerCase
Corsair 750TX 750W Cooler Master HAF 932 Full Tower 
  hide details  
Reply