Search
 
SCRIPT & CODE EXAMPLE
 

CPP

array of charcter c++

//string using array of charcters 
#include <iostream>
#include <cstdlib>
#include <cstring>


using namespace std;

int main(){
    
  char ch1[5]={'a','b','c','d',''};     //()=NULL
  char ch2[4]="HHH";
  cout <<"ch1: " << ch1 << endl;
  cout <<"ch2: " << ch2 << endl;
  
  //copying string to another
  strcpy (ch2,ch1);
  cout <<"ch2 after strcpy: " << ch2 << endl;
  
  //concatinating 2 stringd
  strcat (ch1,ch2);
  cout <<"ch2 after strcat: " << ch1 << endl;
  
  //comparing 2 strings
  cout << strcmp("aaa","bcd");
  // prints(0) if they are equal
  // prints(1) if first < second
  // prints(-1) if second > first
  
  //getting the length of the string
  cout <<"Size of array: " << strlen (ch2);

 
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: valid parentheses in cpp 
Cpp :: tower of hanoi 
Cpp :: create vectors of vectors c++ 
Cpp :: build a prefix array cpp 
Cpp :: nth fibonacci number 
Cpp :: not c++ 
Cpp :: files c++ 
Cpp :: print all subsequences 
Cpp :: virtual function in c++ 
Cpp :: what destructor used for in c++ 
Cpp :: reverse in vector c++ 
Cpp :: std::enable_shared_from_this include 
Cpp :: Round 1 Confusion codechef solution in c++ 
Cpp :: how atan work c++ 
Cpp :: how to get characters through their ascii value in c++ 
Cpp :: remove item from layout 
Cpp :: how to find second smallest element in an array using single loop 
Cpp :: c++ error missing terminating character 
Cpp :: c++ copy vector 
Cpp :: c++ bind port 
Cpp :: cout ascii art c++ 
Cpp :: beecrowd problem 1001 solution in c++ 
Cpp :: private access specifier in c++ program 
Cpp :: case 1 or 2 c++ 
Cpp :: contains in c++ map 
Cpp :: Difference Array | Range update query in O 
Cpp :: solve diamond inheritance c++ 
Cpp :: flowchart to display factors of a number 
Cpp :: C++ Rectangular Form 
Cpp :: 191. Number of 1 Bits leetcode solution in c++ 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =