0% found this document useful (0 votes)
18 views9 pages

IP String

Uploaded by

shadowlord967
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views9 pages

IP String

Uploaded by

shadowlord967
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Introduction To

Programming
Content
• String
String
• C++ uses the <string.h> header file to provide the prototypes.
• Most frequently used functions: strlen(), strcat(), strcat(), strcmp(),
strncmp(), strcpy(), and strchr().

#include<iostream>
#include<string.h>
Using namespace std;
String...
strcat (s1, s2)
#include<iostream>
#include <string.h>
using namespace std;

int main()
{
char course1[]= "My course is: ";
char course2[]= "C++";
strcat(course1, course2);
cout<<course1;
return 0;
}
String...
• strcmp (s1, s2)
#include<iostream>
#include <string.h>
using namespace std;

int main()
{
cout<<strcmp("HE","SHE")<<endl;
cout<<strcmp("SHE","SHE")<<endl;
cout<<strcmp("SHE","HE")<<endl;
cout<<strcmp("HEE","SHE")<<endl;
return 0;
}
String...
• strcpy (s1, s2)
#include<iostream>
#include <string.h>
using namespace std;

int main()
{
char course1[]= "C++";
char course2[5];
strcpy(course2, course1);
cout<<"Course is: "<<course2;
return 0;
}
String...
• strlen (s)
#include<iostream>
#include <string.h>
using namespace std;

int main()
{
char course[]= "C++";
int length = strlen(course);
cout<<"Length is: "<<length;
return 0;
}
String…
String...

You might also like