Write a function named upper which takes as input a char array of size 255 and converts it to uppercase. In the main get a string from the user (fgets) and pass it to the upper as an argument. Once the function call is completed, the main should display the modified char array.
#include <cctype>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
void upper(char s[255]){
for (int i=0; i<strlen(s); i++)
putchar(toupper(s[i]));
}
int main()
{
char str[255];
cout<<"Input a sting to convert to uppercase...\n";
fgets(str, 255, stdin);
cout << "The uppercase of """ << str << """ is\n";
upper(str);
return 0;
}
Comments
Leave a comment