Home > Software design >  Why do we use strings (the value between the double quosts)
Why do we use strings (the value between the double quosts)

Time:03-26

Why do we use strings (the value between the double quosts). please help me

Why do we use strings (the value between the double quosts). Help me please

CodePudding user response:

To store or show text, without string we can't store or show texts.

CodePudding user response:

This is an array of chars with the size of the length of the word inside the quote, inside another place for a special character, which is '\0'. That means the size of the array is the length 1

what makes the string so powerful is the '\0' character.

Instead of already knowing the length of a string, you can iterate it with two known looping ways, for loop and while loop:

for (int i = 0; str[i] != '\0'; i  )
{
    Enter your code here;
}

OR

int i = 0;
while (str[i] != '\0')
{
    Enter your code here;
    i  ;
}
  • Related