R
Randy Rieger
Background: I use DJGPP with these arguments to make sure its standard C
-ansi -W -Wall -pedantic
I have a simple script (below).
My problem is everytime I compile it, it gives a warning saying 'implicit
declaration of function 'toupper', and again for tolower. I don't
understand what I'm doing wrong. Can someone help me
#include <stdio.h>
/*We need to include this header file in order to use the functions below*/
#include <string.h>
#include <stdlib.h>
int main()
{
char first[20], second[20];
int x;
printf("Enter first string: ");
scanf("%s",first);
printf("Enter second string: ");
scanf("%s", second);
/* change case of string to 'UPPER CASE'
- some would like to use strupr(), but this isn't Standard C. So...
we use a loop to run through all the characters in our string, using
toupper()
on each one */
for (x=0; x<strlen(first); ++x)
{
first[x] = toupper(first[x]);
}
printf("Now let's convert the first string to upper case!\n");
printf("We get: %s\n\n", first);
printf("first is now %s\nsecond is now %s\n\n", first, second);
/* change case of string to 'lower case'
- some would like to use strlwr(), but this isn't Standard C. So...
we use a loop to run through all the characters in our string, using
tolower()
on each one */
for (x=0; x<strlen(first); ++x)
{
first[x] = tolower(first[x]);
}
printf("and back to lower case: %s\n\n", first);
printf("first is now %s\nsecond is now %s\n\n", first, second);
return 0;
}
-ansi -W -Wall -pedantic
I have a simple script (below).
My problem is everytime I compile it, it gives a warning saying 'implicit
declaration of function 'toupper', and again for tolower. I don't
understand what I'm doing wrong. Can someone help me
#include <stdio.h>
/*We need to include this header file in order to use the functions below*/
#include <string.h>
#include <stdlib.h>
int main()
{
char first[20], second[20];
int x;
printf("Enter first string: ");
scanf("%s",first);
printf("Enter second string: ");
scanf("%s", second);
/* change case of string to 'UPPER CASE'
- some would like to use strupr(), but this isn't Standard C. So...
we use a loop to run through all the characters in our string, using
toupper()
on each one */
for (x=0; x<strlen(first); ++x)
{
first[x] = toupper(first[x]);
}
printf("Now let's convert the first string to upper case!\n");
printf("We get: %s\n\n", first);
printf("first is now %s\nsecond is now %s\n\n", first, second);
/* change case of string to 'lower case'
- some would like to use strlwr(), but this isn't Standard C. So...
we use a loop to run through all the characters in our string, using
tolower()
on each one */
for (x=0; x<strlen(first); ++x)
{
first[x] = tolower(first[x]);
}
printf("and back to lower case: %s\n\n", first);
printf("first is now %s\nsecond is now %s\n\n", first, second);
return 0;
}