Hi, I was making a program like an array which reads the list and tells what position is it in the list.
For example:
For letters its: list[2]{'A','B'};Its like a search program and it works because it reads the list. So now I was figuring out on how it will read words that are in arrays like dog, cat, mouse etc.. is it like this? list[][3]={"dog","cat"}? Any suggestions on how it can be done by using the concept of arrays?
botter911
-2
Light Poster
Recommended Answers
Jump to Post#include <string> ... string myArray[] = {"Cat", "Dog", "House"};
Hope that helps,
Chris
Jump to PostI should of added its a member of the std namespace.
#include <string> #include <iostream> int main(void){ std::string myArray[] = {"Cat", "Dog", "House"}; for(int i = 0; i < sizeof(myArray)/sizeof(*myArray); i++){ std::cout << myArray[i] << std::endl; } std::cin.get(); return 0; }
Chris
Jump to PostPlease just post the code, the download doesn't work anyway.
Doesn't matter how long it is. And make sure you use [code] tags
Chris
Jump to PostYou need to update your functions to take string arguments rather than char's.
Also your selection sort will not work on strings, as far as i am aware.
You should be using int main(void) and return 0 !
Also are you sure that this is C++ and not …
All 15 Replies
Freaky_Chris
299
Master Poster
botter911
-2
Light Poster
Freaky_Chris
299
Master Poster
botter911
-2
Light Poster
Freaky_Chris
299
Master Poster
botter911
-2
Light Poster
Freaky_Chris
299
Master Poster
botter911
-2
Light Poster
Freaky_Chris
299
Master Poster
botter911
-2
Light Poster
Freaky_Chris
299
Master Poster
botter911
-2
Light Poster
Freaky_Chris
299
Master Poster
botter911
-2
Light Poster
Freaky_Chris
299
Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.