Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to generate the length of a string without using len
funtion?

Answers were Sorted based on User's Feedback



how to generate the length of a string without using len funtion?..

Answer / shruti

** same as above.. only u should initialise the valued of
varibale len to 0..
otherwise it will pick up some garbage value.. **


int strlength(char s[])
{
int i , len;

len = 0;
for(i = 0 ; s[i] != '/0' ; i++)
{
len++;
}

return len;
}

Is This Answer Correct ?    8 Yes 0 No

how to generate the length of a string without using len funtion?..

Answer / poornima

#include<stdio.h>
int strlength(char *);
int main()
{
char *str;
int len;
printf("Enter a string : ");
gets(str);
len=strlength(str);
printf("Length of %s is %d",str,len);
return 0;
}
int strlength(char *str)
{
int len=0;
for(;*str!='\0';str++)
{
len++;
}
return len;
}

Is This Answer Correct ?    2 Yes 0 No

how to generate the length of a string without using len funtion?..

Answer / shreesha vailaya


int strlength(char s[])
{
int i,len;
for(i=0;s[i];i++)
len++;
return len;
}

Is This Answer Correct ?    4 Yes 4 No

how to generate the length of a string without using len funtion?..

Answer / dattathreya

The below function should do it:

int strLength(char *s)
{
int i;
for(i = 0; s[i]; i++);
return i;
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

1.What is a Data Structure? Explain its need? 2.What is a Directed Graph? Write an algorithm to find whether a Directed Graph is connected or not? 3.Explain the process of converting a Tree to a Binary Tree.

4 Answers   Ignou, TCS,


What is static volatile in c?

0 Answers  


What is structure in c language?

0 Answers  


What ios diff. Between %e & %f?

3 Answers   Honeywell,


why TCS selected more student in the software field from all institution.

5 Answers   TCS,


What is meant by initialization and how we initialize a variable?

0 Answers  


With the help of using classes, write a program to add two numbers.

0 Answers   TCS,


what is the first address that gets stored in stack according to a C or C++ compiler???? or what will be the first address that gets stored when we write a C source code????????

2 Answers   Apple,


define c

6 Answers   HCL, TCS,


Find occurence of a character in a sting.

3 Answers   TCS,


What will be the output of x++ + ++x?

20 Answers   MBT, Religare,


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

0 Answers  


Categories