![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
how to initialize a char matrix matrix with empty elements?hello guys!
i have a problem (don't know why) and need some help I have a matrix se part of the code below CPP / C++ / C Code:
If a remove this statement everything is correct but i get some strange (random character) at the empty matrix element when i print it on the screen Can somebody tell me how do i intialize an element of the matrix with an empty character ' ' without geting this error ? |
|
#2
|
|||
|
|||
Re: how to initialize a char matrix matrix with empty elements?Quote:
One way to figure it out is to look at the code How many elements are there in the array? How many times does it go through the loop? (A run time error when you are assigning an value to an array element may be an indication that you are going beyond the limits of the array.) If you can't see it, then make the program tell you what it is working on: CPP / C++ / C Code:
Sometimes I just break out the problem area into a separate small program to make sure nothing else is screwing up the works: CPP / C++ / C Code:
Or, you could simply use the matrix in a more "natural" way: Instead of trying to calculate index values, you could use nested loops: CPP / C++ / C Code:
Regards, Dave |
|
#3
|
|||
|
|||
Re: how to initialize a char matrix matrix with empty elements?Quote:
|
|
#4
|
||||
|
||||
Re: how to initialize a char matrix matrix with empty elements?Please do not double post. I wasted time answering your other post. One post is enough.
__________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#5
|
|||
|
|||
Re: how to initialize a char matrix matrix with empty elements?Quote:
Yes, that works. However... Why not just use the nested loops. That way there's not much question about what it is doing (I suggest that it's likely to be more efficient in terms of machine code and time as well as debugging time.) Regards, Dave |
Recent GIDBlog
Toyota - 2008 November Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to initialize a char matrix matrix with empty elements? | swedenguy | C Programming Language | 1 | 22-Aug-2006 12:15 |
| Combining Vectors and References | Frankg | C++ Forum | 7 | 14-Jan-2006 07:17 |
| Memory cannot be read? | dlare9 | C Programming Language | 3 | 16-Nov-2005 08:03 |
| Debug Assertion Failed! | dlare9 | C Programming Language | 3 | 14-Nov-2005 00:18 |
| Reading non ASCII with read() | Atomical | C Programming Language | 8 | 13-Sep-2005 15:30 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The