| | |
Array/Function problems
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2008
Posts: 3
Reputation:
Solved Threads: 0
I have to create a program with parallele arrays that recieves information from a file telling it how many salsas their are (their can't be more than 10). One array containts the name of the salsa, the other array contains the number of salsa jars sold. Then I have to print the data. I'm not sure why but I keep having alot of problems. If anyone could help me out I would appreciate it.
Thanks, ACRobison02
Thanks, ACRobison02
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int getSalsaData (string [], int[]); void DisplaySalsa (string [], int []); int main () { const int max = 10; string salsa[max]; int numsold[max]; int numsalsa; numsalsa=getSalsaData (salsa, numsold); DisplaySalsa (salsa, numsold); return 0; } int getSalsaData(string salsa[max], int numsold [max]) { int numsalsa; cin>>numsalsa; for (int k=0; k<max; k++) { cin>>salsa[k]; cin>>numsold[k]; } return numsalsa; } void DisplaySalsa(string salsa[max], int numsold[max]) { cout<<"Salsa Type Jars Sold " <<endl; for (int k=0; k<max; k++) { cin>>salsa[k]; cin>>numsold[k]; } }
Last edited by Ancient Dragon; Dec 4th, 2008 at 11:49 pm. Reason: add line numbers
c++ Syntax (Toggle Plain Text)
void DisplaySalsa(string salsa[], int numsold[]) { cout<<"Salsa Type Jars Sold " <<endl; for (int k=0; k<max; k++) { cout<<"salsa["<<k<<"] = "<<salsa[k]<<endl; cout<<"numsold["<<k<<"] = "<<numsold[k]<<endl; } }
![]() |
Similar Threads
- Mapping c# array with COM SAFEARRAY &/or BSTR (C#)
- Return a 2D array from a function (C++)
- Dynamic array management (C)
- Output problems (C++)
- struct array and enum problems (C++)
- C++ pass 2d array into function (C++)
Other Threads in the C++ Forum
- Previous Thread: Adding two angles, need some help
- Next Thread: Can someone help me.
| Thread Tools | Search this Thread |
Tag cloud for C++
api array arrays based beginner binary bmp c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete deploy directshow dll download dynamic encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib library lines linkedlist linker list loop looping loops map math matrix memory microsoft newbie news number output pointer problem program programming project python random read recursion recursive reference return simple spoonfeeding string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






