answersLogoWhite

0

printf does return the length:

size_t len = printf ("%s", str);

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

Write a program that give all the rotations of a string?

#include<stdio.h> #include<string.h> int main() { char a[80]; int rotated_element_number[80]; int rotation; int i; int length; printf("enter the word: \n"); gets(a); length = strlen(a); printf("the reversed string is:\n"); for( rotation=0; rotation<length; rotation++) { for( i=0; i<length; i++) { rotated_element_number[i] = i + rotation; while(rotated_element_number[i] > (length-1)) rotated_element_number[i] -= length; printf("%c", a[rotated_element_number[i]]); } printf("\t"); } getchar(); return 0; }


How to write printf statement for read characters into array str until the letter p is encountered?

In pseudo-code: while ( not(end of string) and letter(string at position X) is not 'P' ){ add(array, newposition) = letter(string at position X); }


Can you print string without using semi column in printf statement in c programming?

If you forget the semicolon, your program won't compile.


Does printf() statement can generate only one line of output?

No, the printf() statement in C can generate multiple lines of output. You can include newline characters (\n) within the string to create line breaks, allowing for formatted output across multiple lines. Additionally, you can call printf() multiple times to print different lines.


Program to find the size of the string in c?

int main (void) { char buf[1024]; scanf ("Enter a string: %s", buf); printf ("The length of the string is %d chars long.\n", strlen (buf)); return 0; }

Related Questions

How do you display a text reversely in C language without using onlu simply input and output?

#include<stdio.h> #include<conio.h> void main() { char string[20]; int i=0; printf("Enter the string.\n"); while(i<=19) { scanf("%c",&string[i]); i++; } while(i>=0) { printf("%c",string[i]); i--; } getch(); } In this program it is compulsory to enter 20 characters. Now we can write a program in which it is not necessary. #include<stdio.h> #include<conio.h> #include<string.h> void main() { char string[20]; int length; printf("enter the string.\n"); gets(string); length=strlen(string); length--; while(length>0) { printf("%c",string[length]); length--; } getch(); }


Write a program that give all the rotations of a string?

#include<stdio.h> #include<string.h> int main() { char a[80]; int rotated_element_number[80]; int rotation; int i; int length; printf("enter the word: \n"); gets(a); length = strlen(a); printf("the reversed string is:\n"); for( rotation=0; rotation<length; rotation++) { for( i=0; i<length; i++) { rotated_element_number[i] = i + rotation; while(rotated_element_number[i] > (length-1)) rotated_element_number[i] -= length; printf("%c", a[rotated_element_number[i]]); } printf("\t"); } getchar(); return 0; }


How to write printf statement for read characters into array str until the letter p is encountered?

In pseudo-code: while ( not(end of string) and letter(string at position X) is not 'P' ){ add(array, newposition) = letter(string at position X); }


WAP using function to print all the rotations of a given string in c language?

#include#include#includeint main() {char a[80];int rotated_element_number[80];int rotation;int i;int length;printf("Enter the word: \n");gets(a);printf("%s\n",a);length = strlen(a);printf("Length is %d\n", length);for( rotation=0; rotation


How to calculate string tension in a musical instrument?

To calculate string tension in a musical instrument, you can use the formula T F L, where T is the tension in the string, F is the force applied to the string, and L is the length of the string between the points where the force is applied. By measuring the force and length of the string, you can calculate the tension.


What is null string?

main(){ char str[5]="hello"; if(str==NULL) printf("string null"); else printf("string not null"); }


Can you print string without using semi column in printf statement in c programming?

If you forget the semicolon, your program won't compile.


Does printf() statement can generate only one line of output?

No, the printf() statement in C can generate multiple lines of output. You can include newline characters (\n) within the string to create line breaks, allowing for formatted output across multiple lines. Additionally, you can call printf() multiple times to print different lines.


What is is null?

main(){ char str[5]="hello"; if(str==NULL) printf("string null"); else printf("string not null"); }


Why printf is used instead of print in c?

The printf() function prints a formatted string.


A C program to print the number of words from given String?

/*We can calculate this with a lot of methods I'll explain only one of them */ *str = "abcd"; // this is a input string printf("%d", strlen(str));


How can one determine the tension in a string?

To determine the tension in a string, you can use the formula T F L, where T is the tension, F is the force applied to the string, and L is the length of the string. By measuring the force and length, you can calculate the tension in the string.