Add to Favorites    Make Home Page 880 Online  
 Language Categories  
 Our Services  

Home » C++ Home » Algorithms Home » string operation

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title string operation
Author akash
Author Email akash_1311 [at] yahoo.co.in
Description
Category C++ » Algorithms
Hits 393210
Code Select and Copy the Code
#include<stdio.h> #include<conio.h> #include<string.h> int STRLEN(char*); int STRCPY(char*,char*); int STRCMP(char*,char*); int STRCAT(char*,char*,char*); int STRREV(char*); void main() { int c; char str[20],str1[10],str2[10],str3[20]; clrscr(); re: printf(" Enter choice=>"); printf(" 1:string len. 2:string copy 3:string cmp. 4:string cat. 5:string rev."); printf(" 6:for exit=>"); scanf("%d",&c);switch(c) { case 1: printf("Enter the string=>"); scanf("%s",&str1); printf("string length=>%d ",STRLEN(str1)); break; case 2: printf(" Enter the string=>"); scanf("%s",str1); STRCPY(str2,str1); printf("copied string=>"); puts(str2); break; case 3: printf("Enter two string=>"); scanf("%s",&str1); scanf("%s",&str2); if(STRCMP(str2,str1)) printf("string is equal"); else printf("String is not equal"); break; case 4: printf("Enter two string=>"); scanf("%s",str1); scanf("%s",str2); STRCAT(str3,str2,str1); puts(str3); break; case 5: printf("Enter the string=>"); scanf("%s",str1); STRREV(str1); printf("Reverse stringis=>"); puts(str1); break; default: goto end; } goto re; end: getch(); } int STRLEN(char *s) { int i=0; while(*s!=NULL) { i++; s++; } return i; } int STRCPY(char *s2,char *s1) { while(*s1!=NULL) { *s2=*s1; s2++; s1++; } *s2=NULL; return 1; } int STRCMP(char *s2,char *s1) { int i=0,len1,len2; len1=strlen(s1); len2=strlen(s2); if(len1==len2) { while(*s2==*s1 && *s2 != NULL && *s1!=NULL) { i++; s1++; s2++; } if(i==len1) return 1; else return 0; } else { return 0; } } int STRREV(char *s) { int len; char *s1; char *ptr; len=strlen(s); s1=(char *)malloc(sizeof(char)); strcpy(s1,s); ptr=s1+len-1; while(*s!=NULL) { *s=*ptr; ptr--; s++; s1++; } *s=NULL; return 1; } int STRCAT(char *s3,char *s2,char *s1) { while(*s1!=NULL) { *s3=*s1; s3++; s1++; } s3++; while(*s2!=NULL) { *s3=*s2; s3++; s2++; } *s3=NULL; return 1; }

Related Source Codes

Script Name Author
Moving ball screen saver karlmarx
The Classic Game of Snake & Ladder Lakshmi Narayana .A
Railway seat reservation question which comes in sapient VyomWorld
To calculate percentile Ravi Mathur
Send to folder ANIMESH SAHU
Analog clock and calendar Nazia & Rida
HIGH/LOW GAME MOLLY ARORA
Data structure (stack Implimentation) Swapnil B Adsure
Memory Game AnirudhSanyal
Easy Calc Anirudh Sanyal
GK Quiz Anirudh Sanyal
Hangman Game Manish Jain
Snakeman Manish Jain
Full month Calendar Nigi
Cursor shapes nigi

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=1157


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review