Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to find length of character array in c++

#include <iostream>

using namespace std;

int main()
{
    char arr[] = "grepper";
    cout << sizeof(arr) << endl;
    return 0;
    //    keep it in mind that character arrays have length of one more than your characters because last one is for  to show that word has ended
}
Comment

c++ length of char array

char* example = "Lorem ipsum dolor sit amet";
int length = strlen(example);
std::cout << length << '
'; // 26
Comment

how to find the size of a character array in c++

Instead of sizeof() for finding the length of strings or character 
arrays, just use strlen(string_name) with the header file
#include <cstring>   
it's easier.
Comment

PREVIOUS NEXT
Code Example
Cpp :: back() in c++ 
Cpp :: factorial function c++ 
Cpp :: concat two vectors c++ 
Cpp :: how to use cout function in c++ 
Cpp :: pascal triangle using c++ 
Cpp :: cpp string slice 
Cpp :: case label in c++ 
Cpp :: c++ double is nan 
Cpp :: long to string cpp 
Cpp :: modulo subtraction 
Cpp :: min heap priority queue c++ 
Cpp :: how to set a variable to infinity in c++ 
Cpp :: function in struct c++ 
Cpp :: arduino xor checksum 
Cpp :: integer to char c++ 
Cpp :: setw c++ 
Cpp :: what is g++ and gcc 
Cpp :: automatic legend matlab 
Cpp :: Max element in an array with the index in c++ 
Cpp :: reversing a string in c++ 
Cpp :: c++ Least prime factor of numbers till n 
Cpp :: cpp map insert 
Cpp :: c++ check if debug or release visual studio 
Cpp :: how to replace part of string with new string c++ 
Cpp :: break statement in c++ program 
Cpp :: cpp execute command 
Cpp :: c++ fonksion pointer 
Cpp :: c++ string_t to string 
Cpp :: how to reset linerenderer unity 
Cpp :: three way comparison operator c++ 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =