Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Newbie - about using toupper/tolower

Reply
Thread Tools

Newbie - about using toupper/tolower

 
 
Randy Rieger
Guest
Posts: n/a
 
      07-07-2003
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;
}




 
Reply With Quote
 
 
 
 
Russell Hanneken
Guest
Posts: n/a
 
      07-07-2003
"Randy Rieger" <> wrote in message
news:cE4Oa.76631$ le.rogers.com...
>
> 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.
>
> #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()


You need to #include <ctype.h> to get the function prototypes for toupper
and tolower.

Regards,

Russell Hanneken




 
Reply With Quote
 
 
 
 
Randy Rieger
Guest
Posts: n/a
 
      07-07-2003
thanks for both your answers guys. Well detailed, I learned something today







 
Reply With Quote
 
Randy Rieger
Guest
Posts: n/a
 
      07-07-2003
thanks for both your answers guys. Well detailed, I learned something today



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie with newbie questions JohnE ASP .Net 3 08-17-2009 10:10 PM
VONAGE Newbie w/newbie question New_kid@nowhere.new VOIP 0 08-11-2007 01:40 PM
another newbie question from another newbie.... Lee UK VOIP 4 05-17-2005 04:10 PM
newbie: cisco vlan newbie question No Spam Cisco 3 06-07-2004 10:02 AM
Newbie! I'm a newbie! What's wrong with this program? Id0x Python 4 07-20-2003 11:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57