how to find string length wihtout using c function?
Answers were Sorted based on User's Feedback
Answer / vignesh1988i
#include<stdio.h>
#include<conio.h>
int str_len(char *)
void main()
{
char s[30];
int count;
printf("enter the string :");
gets(s);
count=str_len(s);
printf("the length is :%d",count);
getch();
}
int str_len(char *a)
{
int i=0;
while(*a!='\0')
a++;
i++;
}
return i;
}
thank u
Is This Answer Correct ? | 5 Yes | 3 No |
Answer / j.j.anand kamlesh
void main()
{
int i;
char ch[100];
printf("ENTER THE STRING :");
gets(ch);
for(i=1;ch[i];i++);
printf("THIS IS THE LENGTH : %d",i);
}
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / ankitecian
int StrLen(const char *_input)
{
int _len = 0;
while( *(_input + _len) != NULL)
{
_len++;
}
return _len;
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / ruchi
#include<conio.h>
#include<stdio.h>
int main()
{
char a[10];
int i=0,c,length=0;
printf("\nEnter the string ");
while((a[i++]=getchar())!='\n');
printf("\nThe lengh of the string is ");
i=i-1;
printf("%d",i);
getch();
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / ramesh
# include <stdio.h>
# include <conio.h>
void main()
{
int i;
char sring[100];
printf("ENTER THE STRING :");
gets(string);
for(i=1;string[i];i++);
printf("LENGTH IS : %d",i);
}
Is This Answer Correct ? | 0 Yes | 0 No |
Explain how can I pad a string to a known length?
Why can’t constant values be used to define an array’s initial size?
How can you increase the size of a dynamically allocated array?
24.what is a void pointer? 25.why arithmetic operation can’t be performed on a void pointer? 26.differentiate between const char *a; char *const a; and char const *a; 27.compare array with pointer? 28.what is a NULL pointer? 29.what does ‘segmentation violation’ mean? 30.what does ‘Bus Error’ mean? 31.Define function pointers? 32.How do you initialize function pointers? Give an example? 33.where can function pointers be used?
There are N egg baskets and the number of eggs in each basket is a known quantity. Two players take turns to remove these eggs from the baskets. On each turn, a player must remove at least one egg, and may remove any number of eggs provided they all belong to the same basket. The player picking the last egg(s) wins the game. If you are allowed to decide who is going to start first, what mathematical function would you use to decide so that you end up on the winning side? Upload a C program to demonstrate the behaviour of the game.
Why is c called c?
difference between Low, Middle, High Level languages in c ?
What is true about the following C Functions (a) Need not return any value (b) Should always return an integer (c) Should always return a float (d) Should always return more than one value
The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
What are the advantages and disadvantages of pointers?
Explain how can I read and write comma-delimited text?
What is c language & why it is used?