SlideShare a Scribd company logo
1 of 45
Download to read offline
Kinan keshkeh 
IT Engineering-Damascus University 
3rd year 
Summer course- 2014 
2 bytes team
Strings !
Strings 
1.C- String (Array of chars ) 
2.Objects from String Classs
C-Strings !
C-Strings 
•It’s an Array of chars ends with ‘ 0 ’ (NULL character) 
•Syntax : 
char Array_Name[Maximum_C-string_Size + 1];
C-Strings 
•char s[10+=“Hi Mom!”
C-Strings 
•It’s an Array of chars ends with ‘ 0 ’ (NULL character) 
•Syntax : 
char Array_Name[Maximum_C-string_Size + 1]; 
•initialize: 
•char arr*+=“kinan” 
•char arr[10+=“kinan” 
•char aString[10]; aString = "Hello";
C-Strings 
•It’s an Array of chars ends with ‘ 0 ’ (NULL character) 
•Syntax : 
char Array_Name[Maximum_C-string_Size + 1]; 
•initialize: 
•char arr*+=“kinan” 
•char arr[10+=“kinan” 
•char aString[10]; aString = "Hello"; 
An Error , you cant write that !!!
C-Strings 
•char arr[5+=,‘k’,’i’,’n’,’a’,’n’-; 
•char arr[10+=,‘k’,’i’,’n’,’a’,’n’-;
C-Strings 
•char arr[5+=,‘k’,’i’,’n’,’a’,’n’-; 
•char arr[10+=,‘k’,’i’,’n’,’a’,’n’-; 
An Error cause the ‘0’ isn’t added 
•char arr[6+=,‘k’,’i’,’n’,’a’,’n’-; 
This is true !
C-Strings 
1.#include <iostream>; 
2.using namespace std; 
3.int main(){ 
4.char A[]="Pascal", B[20]="Ahmad" ; 
5.cout <<"A contains '"<< A<<"'" 
6.<<", its size :"<< sizeof (A) <<endl; 
7.cout <<"B contains '"<< B<<"'" 
8.<<", its size :"<< sizeof (B) <<endl; 
9.} 
A contains 'Pascal', its size :7 
B contains 'Ahmad', its size :20
C-Strings 
1.#include <iostream>; 
2.using namespace std; 
3.int main(){ 
4.char A[]="Pascal", B[20]="Ahmad" ; 
5.cout <<"A contains '"<< A<<"'" 
6.<<", its size :"<< sizeof (A) <<endl; 
7.cout <<"B contains '"<< B<<"'" 
8.<<", its size :"<< sizeof (B) <<endl; 
9.} 
A contains 'Pascal', its size :7 
B contains 'Ahmad', its size :20
C-Strings 
#include <iostream>; using namespace std; int main(){ char ourString[20]="Blaise Pascal" ; int index = 0; while (ourString[index] != '0') { if (ourString[index]==' ') ourString[index]='-'; index++; } cout << ourString; } 
Blaise-Pascal
C-Strings
C-Strings
C-Strings
C-Strings
C-Strings
C-Strings 
•char aString[10]; aString = "Hello"; 
An Error , you cant write that !!! 
•char aString[10]; strcpy(aString ," Hello"); 
But with strcpy u can !!
C-Strings 
#include <iostream> 
#include<cstring> 
using namespace std; 
int main(){ 
char ourString[14]="KINAN" ; 
strcpy(ourString,"keshkeh!!"); 
cout<<ourString<<endl; 
system("pause"); 
return 0 ;} 
keshkeh!!
C-Strings 
#include <iostream> 
#include<cstring> 
using namespace std; 
int main(){ 
char ourString[6]="KINAN" ; 
strcpy(ourString,"keshkehhhhhhhhhhhhhhhhhhhhhhhhhh!!"); 
cout<<ourString<<endl; 
system("pause"); 
return 0 ;} 
keshkehhhhhhhhhhhhhhhhhhhhhhhhhh!! 
compile and run but with warring
C-Strings 
#include <iostream> 
#include<cstring> 
using namespace std; 
int main(){ 
char ourString[20]="Blaise Pascal"; 
if (strcmp(ourString, "Blaise Pascal")) 
cout << "The strings are NOT the same."; 
else 
cout << "The strings are the same."; 
system("pause"); return 0 ;} 
The strings are the same.
C-Strings 
#include <iostream> 
#include<cstring> 
using namespace std; 
int main(){ 
char ourString[20]="Blaise Pascal"; 
cout<<strcmp(ourString, "Blaise Pascal")<<endl; 
system("pause"); return 0 ;} 
0
C-Strings 
The Operation 
Methods 
Input /output 
const int size=10; 
char arr[size]; 
cin>>arr; 
const int max=10; 
char arr[max]; 
cin.getline( arr,max); 
const int max=20; 
char arr[max]; 
cin.get( arr,max,’$’); /* ’$’ when u will end*/ 
cout<<arr; 
cout<<arr; 
cout<<arr; 
ends in Enter+doesn’t take spaces (ex”ki sks” take ”ki” ) 
so you can’t input more than 
Takes the spaces ‘ ‘ ,but doesn’t take Enter if any 
(ex “ ki na n 
keshkeh” , take 
“ki na n“(till Eenter)) 
-Takse Enter + spaces (ex 
“ki n a 
n ke 
shkeh ” take all (till 20 chars)) 
- it can be: cin.get( char);
C-Strings 
cout << "Enter a line of input and I will echo it:n"; char symbol; do { cin.get(symbol); cout << symbol; - while (symbol != ’n’); cout << "That’s all for this demonstration.n"; 
Enter a line of input and I will echo it: 
Do Be Do 1 2 34 
Do Be Do 1 2 34 
That’s all for this demonstration.
Character Manipulation Tools
Character Manipulation Tools
Character Manipulation Tools
Character Manipulation Tools
String !
String 
•It’s a library . 
•Like any type . 
•You can use ‘+’, ‘=’, ‘==’ ,’<=’ .
String
String 
The Operation 
Methods 
Input /output 
String name; 
cin>>name; 
String name; 
getline( cin , name); 
String name; 
getline( cin , name,’$’); 
/* ’$’ when u will end*/ 
cout<<name; 
cout<<name; 
cout<<name; 
ends in Enter+doesn’t take spaces (ex”ki sks” take ”ki” ) 
so you can’t input more than 
Takes the spaces ‘ ‘ ,but doesn’t take Enter if any 
(ex “ ki na n 
keshkeh” , take 
“ki na n“(till Eenter)) 
-Takse Enter + spaces (ex 
“ki n a 
n ke 
shkeh ” take all (till 20 chars))
String 
•You can access the characters in a string object in the same way that you access array elements 
#include<iostream> #include<string> using namespace std; int main( ) { string name="ali"; for (unsigned int i=0;i<name.length();i++) name[i]=toupper(name[i]); //or name.at(i)=toupper(name.at(i)); cout << name << endl; }
String 
•If we have : 
char aCString[] = "This is my C-string."; 
string stringVariable; 
strcpy(aCString, stringVariable); 
aCString = stringVariable; 
aCString = stringVariable.c_str( );
String 
•If we have : 
char aCString[] = "This is my C-string."; string stringVariable; 
strcpy(aCString, stringVariable); 
aCString = stringVariable; 
aCString = stringVariable.c_str( ); 
False !! 
strcpy(stringVariable.c_str( ), aCString); 
True !!
String
String
Code discussion 4
Code discussion 4
Code discussion 4
Code discussion 4
Code discussion 4
That’s for today 
Have a good day ! 
Bye Bye !
2 bytes team 
Group : group link 
Mobile phone- Kinan : 0994385748 
Facebook account : kinan’s account 
2 bytes team

More Related Content

What's hot (20)

Go Containers
Go ContainersGo Containers
Go Containers
 
Documento de acrobat2
Documento de acrobat2Documento de acrobat2
Documento de acrobat2
 
CBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical fileCBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical file
 
Sol7
Sol7Sol7
Sol7
 
Swift School #1
Swift School #1Swift School #1
Swift School #1
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
Pointer level 2
Pointer   level 2Pointer   level 2
Pointer level 2
 
The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.3 book - Part 40 of 184
 
Array using recursion
Array using recursionArray using recursion
Array using recursion
 
programming fundamentals
programming fundamentalsprogramming fundamentals
programming fundamentals
 
Regular expressions, Alex Perry, Google, PyCon2014
Regular expressions, Alex Perry, Google, PyCon2014Regular expressions, Alex Perry, Google, PyCon2014
Regular expressions, Alex Perry, Google, PyCon2014
 
Sortings
SortingsSortings
Sortings
 
ECMAScript 5: Новое в JavaScript
ECMAScript 5: Новое в JavaScriptECMAScript 5: Новое в JavaScript
ECMAScript 5: Новое в JavaScript
 
Pointer level 2
Pointer   level 2Pointer   level 2
Pointer level 2
 
C- Programs - Harsh
C- Programs - HarshC- Programs - Harsh
C- Programs - Harsh
 
Goroutines and Channels in practice
Goroutines and Channels in practiceGoroutines and Channels in practice
Goroutines and Channels in practice
 
Hybrid Inheritance in C++
Hybrid Inheritance in C++Hybrid Inheritance in C++
Hybrid Inheritance in C++
 
lldb – Debugger auf Abwegen
lldb – Debugger auf Abwegenlldb – Debugger auf Abwegen
lldb – Debugger auf Abwegen
 
A Shiny Example-- R
A Shiny Example-- RA Shiny Example-- R
A Shiny Example-- R
 
Class array
Class arrayClass array
Class array
 

Similar to 2 BytesC++ course_2014_c8_ strings

Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxJumanneChiyanda
 
INDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptx
INDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptxINDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptx
INDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptxAbhimanyuChaure
 
Presentation more c_programmingcharacter_and_string_handling_
Presentation more c_programmingcharacter_and_string_handling_Presentation more c_programmingcharacter_and_string_handling_
Presentation more c_programmingcharacter_and_string_handling_KarthicaMarasamy
 
Module-2_Strings concepts in c programming
Module-2_Strings concepts in c programmingModule-2_Strings concepts in c programming
Module-2_Strings concepts in c programmingCHAITRAB29
 
String in programming language in c or c++
String in programming language in c or c++String in programming language in c or c++
String in programming language in c or c++Azeemaj101
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programmingAppili Vamsi Krishna
 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptxJawadTanvir
 
C++ Strings.ppt
C++ Strings.pptC++ Strings.ppt
C++ Strings.pptDilanAlmsa
 
C Programming Strings.docx
C Programming Strings.docxC Programming Strings.docx
C Programming Strings.docx8759000398
 
fundamentals of c programming_String.pptx
fundamentals of c programming_String.pptxfundamentals of c programming_String.pptx
fundamentals of c programming_String.pptxJStalinAsstProfessor
 
Data structure week 3
Data structure week 3Data structure week 3
Data structure week 3karmuhtam
 

Similar to 2 BytesC++ course_2014_c8_ strings (20)

Strings in c++
Strings in c++Strings in c++
Strings in c++
 
COm1407: Character & Strings
COm1407: Character & StringsCOm1407: Character & Strings
COm1407: Character & Strings
 
Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptx
 
Arrays & Strings.pptx
Arrays & Strings.pptxArrays & Strings.pptx
Arrays & Strings.pptx
 
INDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptx
INDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptxINDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptx
INDIAN INSTITUTE OF TECHNOLOGY KANPURESC 111M Lec13.pptx
 
14 strings
14 strings14 strings
14 strings
 
String
StringString
String
 
Presentation more c_programmingcharacter_and_string_handling_
Presentation more c_programmingcharacter_and_string_handling_Presentation more c_programmingcharacter_and_string_handling_
Presentation more c_programmingcharacter_and_string_handling_
 
Module-2_Strings concepts in c programming
Module-2_Strings concepts in c programmingModule-2_Strings concepts in c programming
Module-2_Strings concepts in c programming
 
String in c
String in cString in c
String in c
 
String in programming language in c or c++
String in programming language in c or c++String in programming language in c or c++
String in programming language in c or c++
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
 
C++ Strings.ppt
C++ Strings.pptC++ Strings.ppt
C++ Strings.ppt
 
C Programming Strings.docx
C Programming Strings.docxC Programming Strings.docx
C Programming Strings.docx
 
fundamentals of c programming_String.pptx
fundamentals of c programming_String.pptxfundamentals of c programming_String.pptx
fundamentals of c programming_String.pptx
 
Data structure week 3
Data structure week 3Data structure week 3
Data structure week 3
 
lecture5.ppt
lecture5.pptlecture5.ppt
lecture5.ppt
 

More from kinan keshkeh

10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)kinan keshkeh
 
Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods kinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptkinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptkinan keshkeh
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm kinan keshkeh
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...kinan keshkeh
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graphkinan keshkeh
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_unitskinan keshkeh
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_listskinan keshkeh
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked listkinan keshkeh
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointerskinan keshkeh
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfileskinan keshkeh
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfileskinan keshkeh
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_recordskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templateskinan keshkeh
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphismkinan keshkeh
 

More from kinan keshkeh (20)

10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)
 
Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism
 

Recently uploaded

Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Recently uploaded (20)

Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

2 BytesC++ course_2014_c8_ strings

  • 1. Kinan keshkeh IT Engineering-Damascus University 3rd year Summer course- 2014 2 bytes team
  • 3. Strings 1.C- String (Array of chars ) 2.Objects from String Classs
  • 5. C-Strings •It’s an Array of chars ends with ‘ 0 ’ (NULL character) •Syntax : char Array_Name[Maximum_C-string_Size + 1];
  • 7. C-Strings •It’s an Array of chars ends with ‘ 0 ’ (NULL character) •Syntax : char Array_Name[Maximum_C-string_Size + 1]; •initialize: •char arr*+=“kinan” •char arr[10+=“kinan” •char aString[10]; aString = "Hello";
  • 8. C-Strings •It’s an Array of chars ends with ‘ 0 ’ (NULL character) •Syntax : char Array_Name[Maximum_C-string_Size + 1]; •initialize: •char arr*+=“kinan” •char arr[10+=“kinan” •char aString[10]; aString = "Hello"; An Error , you cant write that !!!
  • 9. C-Strings •char arr[5+=,‘k’,’i’,’n’,’a’,’n’-; •char arr[10+=,‘k’,’i’,’n’,’a’,’n’-;
  • 10. C-Strings •char arr[5+=,‘k’,’i’,’n’,’a’,’n’-; •char arr[10+=,‘k’,’i’,’n’,’a’,’n’-; An Error cause the ‘0’ isn’t added •char arr[6+=,‘k’,’i’,’n’,’a’,’n’-; This is true !
  • 11. C-Strings 1.#include <iostream>; 2.using namespace std; 3.int main(){ 4.char A[]="Pascal", B[20]="Ahmad" ; 5.cout <<"A contains '"<< A<<"'" 6.<<", its size :"<< sizeof (A) <<endl; 7.cout <<"B contains '"<< B<<"'" 8.<<", its size :"<< sizeof (B) <<endl; 9.} A contains 'Pascal', its size :7 B contains 'Ahmad', its size :20
  • 12. C-Strings 1.#include <iostream>; 2.using namespace std; 3.int main(){ 4.char A[]="Pascal", B[20]="Ahmad" ; 5.cout <<"A contains '"<< A<<"'" 6.<<", its size :"<< sizeof (A) <<endl; 7.cout <<"B contains '"<< B<<"'" 8.<<", its size :"<< sizeof (B) <<endl; 9.} A contains 'Pascal', its size :7 B contains 'Ahmad', its size :20
  • 13. C-Strings #include <iostream>; using namespace std; int main(){ char ourString[20]="Blaise Pascal" ; int index = 0; while (ourString[index] != '0') { if (ourString[index]==' ') ourString[index]='-'; index++; } cout << ourString; } Blaise-Pascal
  • 19. C-Strings •char aString[10]; aString = "Hello"; An Error , you cant write that !!! •char aString[10]; strcpy(aString ," Hello"); But with strcpy u can !!
  • 20. C-Strings #include <iostream> #include<cstring> using namespace std; int main(){ char ourString[14]="KINAN" ; strcpy(ourString,"keshkeh!!"); cout<<ourString<<endl; system("pause"); return 0 ;} keshkeh!!
  • 21. C-Strings #include <iostream> #include<cstring> using namespace std; int main(){ char ourString[6]="KINAN" ; strcpy(ourString,"keshkehhhhhhhhhhhhhhhhhhhhhhhhhh!!"); cout<<ourString<<endl; system("pause"); return 0 ;} keshkehhhhhhhhhhhhhhhhhhhhhhhhhh!! compile and run but with warring
  • 22. C-Strings #include <iostream> #include<cstring> using namespace std; int main(){ char ourString[20]="Blaise Pascal"; if (strcmp(ourString, "Blaise Pascal")) cout << "The strings are NOT the same."; else cout << "The strings are the same."; system("pause"); return 0 ;} The strings are the same.
  • 23. C-Strings #include <iostream> #include<cstring> using namespace std; int main(){ char ourString[20]="Blaise Pascal"; cout<<strcmp(ourString, "Blaise Pascal")<<endl; system("pause"); return 0 ;} 0
  • 24. C-Strings The Operation Methods Input /output const int size=10; char arr[size]; cin>>arr; const int max=10; char arr[max]; cin.getline( arr,max); const int max=20; char arr[max]; cin.get( arr,max,’$’); /* ’$’ when u will end*/ cout<<arr; cout<<arr; cout<<arr; ends in Enter+doesn’t take spaces (ex”ki sks” take ”ki” ) so you can’t input more than Takes the spaces ‘ ‘ ,but doesn’t take Enter if any (ex “ ki na n keshkeh” , take “ki na n“(till Eenter)) -Takse Enter + spaces (ex “ki n a n ke shkeh ” take all (till 20 chars)) - it can be: cin.get( char);
  • 25. C-Strings cout << "Enter a line of input and I will echo it:n"; char symbol; do { cin.get(symbol); cout << symbol; - while (symbol != ’n’); cout << "That’s all for this demonstration.n"; Enter a line of input and I will echo it: Do Be Do 1 2 34 Do Be Do 1 2 34 That’s all for this demonstration.
  • 31. String •It’s a library . •Like any type . •You can use ‘+’, ‘=’, ‘==’ ,’<=’ .
  • 33. String The Operation Methods Input /output String name; cin>>name; String name; getline( cin , name); String name; getline( cin , name,’$’); /* ’$’ when u will end*/ cout<<name; cout<<name; cout<<name; ends in Enter+doesn’t take spaces (ex”ki sks” take ”ki” ) so you can’t input more than Takes the spaces ‘ ‘ ,but doesn’t take Enter if any (ex “ ki na n keshkeh” , take “ki na n“(till Eenter)) -Takse Enter + spaces (ex “ki n a n ke shkeh ” take all (till 20 chars))
  • 34. String •You can access the characters in a string object in the same way that you access array elements #include<iostream> #include<string> using namespace std; int main( ) { string name="ali"; for (unsigned int i=0;i<name.length();i++) name[i]=toupper(name[i]); //or name.at(i)=toupper(name.at(i)); cout << name << endl; }
  • 35. String •If we have : char aCString[] = "This is my C-string."; string stringVariable; strcpy(aCString, stringVariable); aCString = stringVariable; aCString = stringVariable.c_str( );
  • 36. String •If we have : char aCString[] = "This is my C-string."; string stringVariable; strcpy(aCString, stringVariable); aCString = stringVariable; aCString = stringVariable.c_str( ); False !! strcpy(stringVariable.c_str( ), aCString); True !!
  • 44. That’s for today Have a good day ! Bye Bye !
  • 45. 2 bytes team Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 2 bytes team