|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
How to store space in a array in a C program Well i am not so new with the 'C' programming language, but after trying hard to debug, i still cannot get why my code unable to print spaces when i dont see any problems with it ![]() code : Code: while( i < 10) { arr[i] = (char)" "; i++; } Last edited by NetworkeR : 03-11-2009 at 12:27 PM. |
#2
| |||
| |||
Re: How to store space in a array in a C program The code looks good, but please check if you initialized the integer variable "i" before you used it in the while loop, also what is the size of the array that you have declared. also check if all the braces used are properly placed.. Please let me know if the "spaces" are still not printed. |
#3
| |||
| |||
Re: How to store space in a array in a C program kelfro I have checked those several times. The integer variable "i" has been initialized to "0", the array "arr" has been declared so as to save "10" characters. Also all the braces are at their respective places. Now what...??? |
#4
| |||
| |||
Re: How to store space in a array in a C program Theres a lot of difference between" " and ' '. ' ' is how the space character is denoted whereas " " is a string which is totally different from the space character which you want to print. so if you just replace the " " with ' ', your program should give you 10 spaces in the array that you need. code: Code: while( i < 10) { arr[i] =' '; i++; } Last edited by MindSpace : 03-11-2009 at 12:45 PM. |
![]() |
|
Tags: array, c programming, char, debug |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Not enough space to store temporary Windows installation files | UselessGuy | Operating Systems | 3 | 17-12-2010 06:44 AM |
Program to print an 2D array | Sarfaraj Khan | Software Development | 5 | 03-02-2010 02:59 PM |
Store content of file in array of bytes | Aaliya Seth | Software Development | 5 | 21-01-2010 01:25 PM |
How to store byte array to database with JDBC? | RogerFielden | Software Development | 3 | 23-09-2009 10:52 AM |
Three Dimensional Array program in Java. | nonose | Software Development | 3 | 10-08-2009 07:49 PM |