Re: [Dev-C++] how to pass a string array to another function
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: Brad <nyc...@gm...> - 2012-09-17 21:34:04
|
My data is almost in its function but I am having difficulties with the final step. Goal: To get the array data into a textbox window on line 406 and 407 of -> http://pastie.org/4742333 But I am getting this error http://pastie.org/4742347 and I have tried a few different versions of passing the argument but no success. The array data is generated by my case statements starting on line 79 on http://pastie.org/4742337 in my main() <following earlier recommendations> This last screw is giving me fits. :( Brad From: bibigiu [mailto:bi...@al...] Sent: Monday, September 17, 2012 8:04 AM To: Brad Subject: Re: [Dev-C++] how to pass a string array to another function Il 17/09/2012 13:40, Brad ha scritto: My situation is this, I have a string array that I am trying to get the data to another function but have issues with the return type conflicting with either the function definition or the array data being passed. std::array Array[2] std::string f() { array[0]=ted array[1]=bundy return Array[2]; }}; void printarray (int arg[], int length) { for (int n=0; n<length; n++) cout << Array[n] << endl; } int main () { printarray(); return 0; } try this : #include <iostream> using namespace std; void PrintArray(std::string str[],int length) { for(int a=0;a<length;a++) { cout<< str[a].c_str() << endl; } } int main() { std::string str[2]; str[0] = "hello"; str[1] = "bye"; PrintArray(str,2); return 0; } ---------------------------------------------------------------------------- -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |