Start New Discussion within our Software Development Community

I have an issue with a function not working properly in my code --

It is a calendar creating program and when I call the function from the menu it blips the first line of text that it outputs to the user (asks a question for some input) and then immediately exits without error. I really am not sure what is doing this but below I have included the necessary code

void htmlOutput(int specialEventsCount, apvector<apstring> &EventsNames, apvector<int> &EventDateCount);


int main()
{

    int specialEventsCount;
    apvector<apstring> EventsNames;
    apvector<int> EventDateCount;
    
    EventsNames.resize(specialEventsCount);
    EventDateCount.resize(specialEventsCount);

.....

 case 4 : htmlOutput(specialEventsCount,EventsNames,EventDateCount); break;

}

void htmlOutput (int specialEventsCount, apvector<apstring> &EventsNames, apvector<int> &EventDateCount)
{

     int j, n,               //Counter for loop
         monthDaysDos;       //Month days set = to integer
     apstring firstDayName,  //First weekday of month
              monthDays;     //Asks user via apstring
     apvector<int> date;
     
     //
     apvector<apstring> EventsNames;
     EventsNames.resize(specialEventsCount);
     //
     
     date.resize(monthDaysDos);

     cout << "What day of the week is the first day of the month?" << endl;
     cout << "Please type in the full day name: ";
     getline(cin,firstDayName);

When I run this by itself if I put it in int main and add the variables that are referenced in there, it works perfectly.

This article has been dead for over six months. Start a new discussion instead.