how to generate the length of a string without using len
funtion?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
main() { intj; while9j<=10) { printf("\n%d",j); j=j+1; } }
What is the difference between constant pointer and pointer to a constant. Give examples.
What is key word in c language?
What is main function in c?
Explain output of printf("Hello World"-'A'+'B'); ?
What is sizeof in c?
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
What is omp_num_threads?
how to use showbits function?
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?
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 ?