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

main() { intj; while9j<=10) { printf("\n%d",j); j=j+1; } }

4 Answers  


What is the difference between constant pointer and pointer to a constant. Give examples.

4 Answers   TCS,


What is key word in c language?

4 Answers   ABC,


What is main function in c?

0 Answers  


Explain output of printf("Hello World"-'A'+'B'); ?

0 Answers  


What is sizeof in c?

0 Answers  


please help me..... please codes and flowchart plz turbo c lang po yan.....please asap response... 3. Make an astrology program. The user types in his or her birthday (month, day, and year as integer), and the program responds with the user’s zodiac sign, horoscope, and other information related to it. If the user’s birth year falls into a leap year, your program should display an appropriate message for it. NOTES: Conditional Statements: it should be with graphics

0 Answers  


What is omp_num_threads?

0 Answers  


how to use showbits function?

2 Answers   Infosys, TATA,


what will be the output: main(){char ch;int a=10;printf("%d",ch);}

36 Answers   Accenture, TCS, Wipro,


Where are some collections of useful code fragments and examples?

0 Answers   Celstream,


we have to use realloc only after malloc or calloc ? or we can use initially with out depending on whether we are using malloc or calloc in our program ?

2 Answers  


Categories