Wednesday, August 17, 2011

QUES 13 STRING CONV(UP to LO and LO to UP)(CmdLineARG)


C LANGUAGE BOOK






 Command Line Argument:-

 A Command Line Argument is the information that follow the program name on the command line of the operating system.each command line argument is separated by space or tab.
Note:-commas,semicolons,and the like are not considered separators.

.when you compile a program you type at the command prompt something like
cc programname

in this program suppose you save abc.c.it take two command line argument.
argv[0] is  programname
argv[1] is argument.

you type at the command prompt to compile..
cc programname hello

here argv[1]=hello



WAP TO PERFORM STRING CONVERSION UPPER CASE TO LOWER CASE (OR LOWER CASE TO UPPER CASE) USING COMMAND LINE ARGUMENT.

#include<stdio.h>

main(int argc,char *argv[1])
{
int i;
if(argc != 2)
{
  printf("YOU FORGET TO TYPE YOUR ARGUMENTS");
  exit(1);
}
for(i=0;i<argc;i++)
 convers_(argv[i]);


return 0;
}
convers_(char *chh)
{

char ch;
 printf("TYPE YOUR ARGUMENTS");

while (*chh)
{
ch=*chh;

if(islower(ch))
 {
  ch = toupper(ch);
  printf("\nTHE CHARACTER IN UPPERCASE IS : %c",ch);
 }
 else
 if(isupper(ch))
 {
  ch = tolower(ch);
  printf("\nTHE CHARACTER IN LOWERCASE IS : %c",ch);

chh++;
 }

}


}






C LANGUAGE BOOK

No comments:

Post a Comment