I have this code:
Code:
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int check_up(char string[]);
int check_low(char string[]);
void to_up(char string[]);
void to_low(char string[]);
int main()
{ char word[1];
printf("Input a string:");
fgets(word, sizeof(word), stdin);
int up, low;
up= check_up(word);
low= check_low(word);
if( (up==0) && (low ==0)){
printf("%s is neither all uppercase nor all lowercase.\n", word);
}else if( low==1){
printf("%s is all lowercase.\n", word);
}else if( up==1)
printf("%s is all uppercase.\n", word);
}
to_up(word);
printf("All uppercase %s.\n", word);
to_low(word);
printf("All lowercase %s.\n", word);
return 0;
}
//Check if all upper
int allupper(char string[]){
int a;
a = 0;
if ( string[a] == '\n' )
{
string[a] = '\0';
}
isupper(string[a]);
}
//Check if all lower
int alllower(char string[]){
int a;
a = 0;
if ( string[a] == '\n' )
{
string[a] = '\0';
}
islower(string[a]);
}
//Converts to lower
void to_low(char string[]){
int a;
a = 0;
if ( string[a] == '\n' )
{
string[a] = '\0';
}
string[a] = tolower(string[a]);
}
//Converts to upper
void to_up(char string[]) {
int a;
a = 0;
if ( string[a] == '\n' )
{
string[a] = '\0';
}
string[a] = tolower(string[a]);
}
When I compile this I have the following problems:
- warning: data definition has no type or storage class [enabled by default] in 'to_up(word)'
- conflicting types in 'to_up' function and to_low function
- warning: data definition has no type or storage class [enabled by default] into_up function
- error: unknown type name ‘word’ in line 'printf("All uppercase %s.\n", word):;'
- warning: parameter names (without types) in function declaration [enabled by default] in 'to_up(word)'and 'to_low(word)'
- 'note: previous declaration of ‘to_up’ was here in function declaration of to_up function
How I can fix this problems?