Completely Solved C, C++ Programs Assignment.




C Program to accept a string and find the length of the given string by using functions (Process I)

Filed Under:

Problem 45. C Program to accept a string and find the length of the given string by using functions (Process I)
#include<stdio.h>
#include<conio.h>
int getline(char str[]);
main( )
{
char str[80];
int length;
clrscr( );
printf(“ enter a string”);
length=getline(str);
printf(“length of the given string is
%d”,length);
getch ( );
}
int getline(char str[])
{
int i;
for(i=0;i<80&&((str[i]=getchar( ))!=’n’);
i++);
if(str[i]= =’n’)
str[i]=’�’;
return i;
}

C compiler: gcc 4.1.2

 Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments