
Untitled
By: a guest on
May 1st, 2012 | syntax:
None | size: 1.20 KB | hits: 10 | expires: Never
using cstring in c program isnt running whats wrong? [closed]
#include <iostream>
#include <cstring>
using namespace std;
void DisplayAllUpper(char& Days);
void DisplayFirstUpper(char& Days);
void DisplayDaysLength(char& Days, int x);
int main()
{
char Days[5][10]={"monday", "tuesday", "wednesday", "thursday", "friday"};//array of days
int x;
DisplayAllUpper(&Days);
DisplayFirstUpper(&Days);
DisplayDaysLength(&Days, x);
return 0;
}
void DisplayAllUpper(char& Days)
{
//Part a: Change Days to all Uppercase
cout<<"Part A" <<endl;
cout << endl;
for(int i=0; i<5; ++i)
{
strupr(Days[i]);
cout << Days[i]<<endl;
}
}
void DisplayFirstUpper(char& Days)
{
//Part B: Change the first letter of each Day to Uppercase
cout<<"Part B" << endl;
cout << endl;
for(int i = 0; i < 5; ++i)
{
Days[i][0] = toupper(Days[i][0]);
cout<<Days[i]<< endl;
}
}
void DisplayDaysLength(char& Days, int x)
{
//Part C: Show Day of the week and how many letters each day of the week is
cout<< "Part C" <<endl;
cout << endl;
for(int i=0; i<5; ++i)
{
int x= strlen(Days[i][0]);
cout << x << endl;
}
}