| | |
Array of strings
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 89
Reputation:
Solved Threads: 2
well, i am quite confused here. You mean to say you want to take input of several strings in a single character array? 
infact, here you are asking for a single character everytime :
> cin >> a[i]
if you meant to count the number of characters, then you may do it using some function like strlen(), or you may put a counter along with input.
Also, the array here is certainly unstable, without '\0' null character.

infact, here you are asking for a single character everytime :
> cin >> a[i]
if you meant to count the number of characters, then you may do it using some function like strlen(), or you may put a counter along with input.
Also, the array here is certainly unstable, without '\0' null character.
Bhoot
•
•
Join Date: Mar 2008
Posts: 89
Reputation:
Solved Threads: 2
If you want only a single string, then its getline().
If you want several strings, then a single array certainly wont do. I wonder how will you differentiate between strings. As you said, if you use '.', still wouldnt it be better if you use a 2-D array of characters, or an array of character pointers?
If you want several strings, then a single array certainly wont do. I wonder how will you differentiate between strings. As you said, if you use '.', still wouldnt it be better if you use a 2-D array of characters, or an array of character pointers?
Bhoot
![]() |
Similar Threads
- Sorting a 2D Array of Strings (C++)
- how to read an array of strings in C++ (C++)
- 2d array of strings (C++)
- Declaring an array of strings in C++ (C++)
- Initializing an array of strings and printing it. (C++)
- Is there a way to tokenize an array of strings (C++)
- filling an array with strings using gets() (C)
Other Threads in the C++ Forum
- Previous Thread: multiplying values that are stored in the array
- Next Thread: Linked List Question
Views: 540 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll dynamic encryption error file forms fstream function functions game givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linker linux loop looping loops map math matrix memory microsoft newbie news number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort stream string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





