Computer Science, asked by asmit1256, 6 months ago

how to calculate length of single and multiple line string​

Answers

Answered by tejaspadol60
0

Explanation:

Use triple quotes to create a multiline string

It is the simplest method to let a long string split into different lines. You will need to enclose it with a pair of Triple quotes, one at the start and second in the end. Anything inside the enclosing Triple quotes will become part of one multiline string.

Answered by mad210202
0

Answer:

Calculating length of single line string and multiple line string​.

Explanation:

Calculating length of single line string.

int len(char *str)

{

   int count = 0;

   while(*str++)

       count++;

   return count;

}

Calculating length of multiple line string.

given string is:

string="this is a sample

this is a second sample

same length the 1 above

this is a third sample"

Code for calculating:

printf '%s\n' "$string" | awk -v max=-1 '

 {l = length}

 l > max {max = l; output = "Max length: " max RS}

 l == max {output = output NR ": " $0 RS}

 END {if (max >= 0) printf "%s", output}'

Similar questions