Posts

Showing posts with the label String

C program source code to print reversed string using string function

C program source code to print reversed string using string function
Write a C program  to print reversed string using string function C Program source code#include<stdio.h> #include<conio.h> #include<string.h> int main() { char name[100]; printf("Enter any character:"); gets(name); strrev(name); printf("The character after reversing is:"); puts(name); getch(); return 0; }
You can Browse related article below for more information and program code related to string function

 Does above is helpful , Post you views in comment
DO NOT MISS OTHER C PROGRAMMING TUTORIAL* indicates required Email Address *


C program source code to print string length using strlen

C program source code to print string length using strlen
Write a C program  to print  string length using strlen C Program source code#include<stdio.h> #include<conio.h> #include<string.h> int main() { char name[100]; printf("Enter the character:"); gets(name); int k; k=strlen(name); printf("The length of the string is:%d",k); getch(); return 0; }
You can Browse related article below for more information and program code related to string function

 Does above is helpful , Post you views in comment
DO NOT MISS OTHER C PROGRAMMING TUTORIAL* indicates required Email Address *


C program source code to print reversed string

C program source code to print reversed string
Write a C program  to print reversed string C Program source code#include<stdio.h> #include<string.h> #include<conio.h> int main() { char a[100]; int i,n; printf("Enter any word:\n"); gets(a); n=strlen(a); printf("The reversed array is:\n" ); for(i=n-1; i>=0; i--) printf("%c",a[i]); getch(); return 0; }
You can Browse related article below for more information and program code related to recursive function call

 Does above is helpful , Post you views in comment
DO NOT MISS OTHER C PROGRAMMING TUTORIAL* indicates required Email Address *


Sort character of string in ascending or descending order

Sort character of string in ascending or descending order
Write a program to sort set of strings in ascending and descending order of their ... char Ascending #include <stdio.h> #include <conio.h> #include <string.h> int main () {     int n , i ,j ;     char name[100] , temp;     scanf("%s", name);     n = strlen(name);     for (i=0 ; i<n ; i++)     {         for(j=i+1 ; j<n ;j++)         {             if(name[i] > name[j])             {             temp = name[i]    ;             name[i] = name[j] ;             name[j] = temp;             }         }     } printf("\n%s" , name); getch() ; return 0 ;    } Descending #include <stdio.h> #include <conio.h> #include <string.h> int main () {     int n , i ,j ;     char name[100] , temp;     scanf("%s", name);     n = strlen(name);     for (i=0 ; i<n ; i++)     {         for(j=i+1 ; j<n ;j++)         {             if(name[i] < name[j])             {    …

what everybody ought to know about string in c.

Image
String in C You will be able to :>> Define string>>Declaration of String>>Initialization of String>>Use string handling function String
In C programming, array of character are called strings. A string is terminated by null character /0.


Array is the collection of similar data under common name.


A common name is the name of string or array.For example:

char stringname  = "Hello";  Here stringname is common name .We will study String Decleration below Section.


 C  compiler represent above string as below image (string representation)


Declaration of String
It is declared as:


char string_name[size];

E.g: char name[10];


Strings can also be declared using pointer.
char *p
Initialization of String
It can be initialized when they are declared


char c[]="abcd";      OR, char c[5]="abcd";      OR, char c[]={'a','b','c','d','\0'};      OR; char c[5]={'a','b','c','d'…