Strings programs

 

Program with gets() & puts()

#include<stdio.h>
#include<conio.h>
void main()
{
    char s[90];
    gets (s);
    // puts will not work without gets
    puts (s);
    // but gets work without puts
    printf("%s",s);
}

Output:








Program with fgets() & puts()

#include<stdio.h>
#include<conio.h>
void main()
{
    char s[90];
    fgets (s,10,stdin);
    // puts will not work without gets
    puts (s);
    // but gets work without puts
    printf("%s",s);
}

Output:










Program with string functions

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    char s[90]={"vishal"};
    char d[90]={"VISHAL"};
    /*strrev(s);
    printf("%s",s);*/
    //int t=strlen(s);
    //strcpy(d,s);
    //printf("length of string is %s", strcat(s,d));
    /*if(strcmp(s,d)==0)
    {
        printf("equal");
    }
    else
    {
        printf("unequal");
    }*/
    /*strlwr(d);
    printf("%s",d);*/
   /* strupr(s);
    printf("%s",s);*/
   
}















No comments:

Post a Comment