| | |
C++ quick question, array
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2009
Posts: 2
Reputation:
Solved Threads: 0
My array keeps outputting this random character (kind of like a # in a box). Anyways, its just garbage really, but how do i stop it from doing this.
If my array was like
char title[10]
and the user inputted something with only 5 characters, then the remaining characters would be the garbage character.
How do I stop this?
If my array was like
char title[10]
and the user inputted something with only 5 characters, then the remaining characters would be the garbage character.
How do I stop this?
•
•
Join Date: Oct 2009
Posts: 9
Reputation:
Solved Threads: 0
-1
#3 32 Days Ago
Are you outputting array with a loop?If so, try putting the condition
C++ Syntax (Toggle Plain Text)
for(i=0;i!=\0;i++) cout<<title[i];
0
#5 32 Days Ago
I believe I know why, although I am not positive. Anyway, my guess would be that the [10] is only initializing the amount of characters you can have in the word. Therefore, in order to have it as an array you would need:
This works for me anyway..
@ancientdragon, wouldn't he need quotes around the character to initialize it? Not positive if you do or not..
C++ Syntax (Toggle Plain Text)
char title[10][25]
This works for me anyway..
@ancientdragon, wouldn't he need quotes around the character to initialize it? Not positive if you do or not..
![]() |
Similar Threads
- quick question (Python)
- Quick question (C++)
- quick question w\ a program (Java)
- nevermind: ignore arrays problem - quick question (C++)
- A quick question about "rank" (DaniWeb Community Feedback)
- Quick question on a loop. (C++)
- A quick question (Game Development)
- quick question (C++)
- strcmp of 2-D array (C)
- Laptop LCD built into a car? (Monitors, Displays and Video Cards)
Other Threads in the C++ Forum
- Previous Thread: Is .NET good option to make a GUI in C++?
- Next Thread: 2 variables in for loop
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg simple sorting string strings temperature template text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






