This blog consists of C and C++ programs. C and C++ programming is the basics to learn any programming language. Most of the programs are provided with their respective outputs. This blog also contains Data Structures programs using Object-Oriented Programming (C++). Some of the best books for learning C and C++ programming are also mentioned.

Showing posts with label String Length. Show all posts
Showing posts with label String Length. Show all posts

Tuesday, 6 August 2013

Program to find the length of the string using strlen() function

#include<stdio.h>
void main()
{
char str[50];
int len;
clrscr();
printf("Enter the text: ");
scanf("%s", str);
len=strlen(str);
printf("Length of the string = %d", len);
getch();
}


Tuesday, 2 July 2013

Program to find the length of the string without using strlen() function

#include <stdio.h>
void main()
{
char s[1000],i;
clrscr();
printf("Enter a string: ");
scanf("%s",s);
for(i=0; s[i]!='\0'; ++i);
printf("Length of string: %d",i);
getch();
}