dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language:
Expertise: Beginner
Apr 5, 2002

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Print the Length of the String Without Using strlen()


The following code reads one string, and prints the length of that without using strlen():
 
#include <stdio.h>
#include <string.h>
int main()

{
	char s[20];
	gets(s);
	printf("  %d ",printf("%s",s));/*return 
type of printf() is int. so it
returns the number of characters it prints.*/
}
Rajani Kanth
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Thanks for your registration, follow us on our social networks to keep up-to-date