Click here to Skip to main content
15,903,175 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to enable the port in menubar? Pin
Iain Clarke, Warrior Programmer13-Sep-04 3:28
Iain Clarke, Warrior Programmer13-Sep-04 3:28 
GeneralCListCtrl Pin
Neelesh K J Jain12-Sep-04 18:44
Neelesh K J Jain12-Sep-04 18:44 
GeneralEncrypt/Decrypt Pin
Timothy Grabrian12-Sep-04 17:13
professionalTimothy Grabrian12-Sep-04 17:13 
GeneralRe: Encrypt/Decrypt Pin
Michael Dunn12-Sep-04 19:23
sitebuilderMichael Dunn12-Sep-04 19:23 
GeneralRe: Encrypt/Decrypt Pin
Alexander M.,13-Sep-04 5:12
Alexander M.,13-Sep-04 5:12 
QuestionHow to use combobox with UNICODE? Pin
Member 135496212-Sep-04 11:17
Member 135496212-Sep-04 11:17 
GeneralPolyline Editor in Open Gl Pin
csp200512-Sep-04 10:24
csp200512-Sep-04 10:24 
GeneralSegmentation fault?! Pin
Whiphub12-Sep-04 9:39
Whiphub12-Sep-04 9:39 
Hello all, I am getting a segmentation fault when trying to access an array... I know this is silly, am I overlooking something? What the hell? The problem seems to occur when accessing an array from the bigFish function. Please teach me..

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;

struct fish{
int contestant[99999];
int fishNumber[99999];
float fishWeight[99999];};
void readFiles(int contest[20], string name[20], int fishNum[5],
string fishType[5], fish fishStruct);
void bigFish(int contest[20], string name[20], int fishNum[5],
string fishType[5], fish fishStruct);

int main()
{
fish fishStruct;
int choice = 0; //choice in menu
cout.setf(ios::fixed, ios::floatfield);
cout.setf(ios::showpoint);
cout.precision(2);

int contest[20];
string name[20];
int fishNum[5];
string fishType[5];
readFiles(contest, name, fishNum, fishType, fishStruct);

cout<<"MENU: PLEASE MAKE A SELECTION"<<endl<<endl;
cout<<"1.="" display="" all="" data="" for="" a="" contestant"<<endl;
="" cout<<"2.="" total="" catch="" weight="" fish="" type"<<endl;
="" cout<<"3.="" largest="" caught"<<endl<<endl;
="" cout<<"choose="" and="" option="" between="" 1-3"<<endl;
="" cin="">>choice;
if (choice == 3)
bigFish(contest, name, fishNum, fishType, fishStruct);
return 0;
}

void readFiles(int contest[20], string name[20], int fishNum[5], string fishType[5], fish fishStruct)
{


ifstream inFile;
inFile.open("contestantname.data");
if (!inFile)
{
cout<<"contestantname.data not found"<<endl;
}
="" clearing="" out="" the="" array
="" for(int="" i="0;" <="" 20;="" i++)
="" {
="" contest[i]="0;
" name[i]=" " ;
="" int="" count1="0;
" while(infile)
="" infile="">>contest[count1];
inFile>>name[count1];
cout<<name[count1]<<endl;
count1++;
="" }
="" infile.close();
=""
="" infile.open("fishtype.data");
="" if="" (!infile)
="" {
="" cout<<"fishtype.data="" not="" found"<<endl;
="" clearing="" out="" the="" array
="" for(int="" i="0;" <="" 20;="" i++)
="" fishnum[i]="0;
" int="" count2="0;
" while(infile)
="" infile="">>fishNum[count2];
inFile>>fishType[count2];
count2++;
}
inFile.close();

inFile.open("catch.data");
if (!inFile)
{
cout<<"catch.data not found"<<endl;
}
="" clearing="" out="" the="" array
="" for(int="" i="0;" <="" 20;="" i++)
="" {
="" fishstruct.contestant[i]="0;
" fishstruct.fishnumber[i]="0;
" fishstruct.fishweight[i]="0;
" int="" count3="0;
" while(infile)
="" infile="">>fishStruct.contestant[count3];
inFile>>fishStruct.fishNumber[count3];
inFile>>fishStruct.fishWeight[count3];
count3++;
}
inFile.close();


}
void bigFish(int contest[20], string name[20], int fishNum[5],
string fishType[5], fish fishStruct)
{
int num = 0; //temp contestant number
int totalWeight = 0; //weight for each contestant
string tempName; //temp contestant name
cout<<"Please enter contestant number"<<endl;
cin="">>num;
for(int i = 0; i < 20; i++)
{
cout<
GeneralRe: Segmentation fault?! Pin
Antti Keskinen12-Sep-04 10:44
Antti Keskinen12-Sep-04 10:44 
GeneralSwitching mainframe menu (solution) Pin
Ravi Bhavnani12-Sep-04 8:23
professionalRavi Bhavnani12-Sep-04 8:23 
GeneralRe: Switching mainframe menu (solution) Pin
KaЯl13-Sep-04 3:55
KaЯl13-Sep-04 3:55 
QuestionHOw to convert from EMF to SWF. Pin
Azghar Hussain12-Sep-04 7:49
professionalAzghar Hussain12-Sep-04 7:49 
AnswerRe: HOw to convert from EMF to SWF. Pin
Christian Graus12-Sep-04 11:52
protectorChristian Graus12-Sep-04 11:52 
QuestionLink/C-calling convention ? Pin
0v3rloader12-Sep-04 6:46
0v3rloader12-Sep-04 6:46 
AnswerRe: Link/C-calling convention ? Pin
Antti Keskinen12-Sep-04 9:38
Antti Keskinen12-Sep-04 9:38 
GeneralRe: Link/C-calling convention ? Pin
0v3rloader12-Sep-04 22:59
0v3rloader12-Sep-04 22:59 
GeneralRe: Link/C-calling convention ? Pin
Antti Keskinen13-Sep-04 4:15
Antti Keskinen13-Sep-04 4:15 
GeneralRe: Link/C-calling convention ? Pin
0v3rloader14-Sep-04 1:47
0v3rloader14-Sep-04 1:47 
GeneralEnvironment macro Pin
Rome Singh12-Sep-04 6:31
Rome Singh12-Sep-04 6:31 
GeneralRe: Environment macro Pin
Andrew Walker12-Sep-04 14:46
Andrew Walker12-Sep-04 14:46 
GeneralRe: Environment macro Pin
Rome Singh13-Sep-04 5:12
Rome Singh13-Sep-04 5:12 
GeneralRe: Environment macro Pin
Andrew Walker13-Sep-04 12:52
Andrew Walker13-Sep-04 12:52 
QuestionWarning: no message line prompt for ID *???? Pin
jettocrack12-Sep-04 6:13
jettocrack12-Sep-04 6:13 
AnswerRe: Warning: no message line prompt for ID *???? Pin
Ravi Bhavnani12-Sep-04 7:13
professionalRavi Bhavnani12-Sep-04 7:13 
GeneralProblem Regarding Tree in DOTNET Pin
eshban28412-Sep-04 6:08
eshban28412-Sep-04 6:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.