Write a program to compare two strings without using the
strcmp() function
Answer Posted / vijay.benzamin
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int c=0;
char a[10];
char b[10];
gets(a);
gets(b);
for(int i=0,j=0;b[i]!='\0'||a[j]!='\0';i++,j++)
{
if(a[i]!=b[j])
{
c++;
}
}
if(c==0)
cout<<"string match";
else
cout<<"string does not match";
getch();
}
| Is This Answer Correct ? | 54 Yes | 31 No |
Post New Answer View All Answers
What is pass by value in c?
difference between object file and executable file
I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...
Which header file is essential for using strcmp function?
What is a substring in c?
What is modifier & how many types of modifiers available in c?
The purpose of this exercise is to benchmark file writing and reading speed. This exercise is divided into two parts. a). Write a file character by character such that the total file size becomes approximately >10K. After writing close the file handler, open a new stream and read the file character by character. Record both times. Execute this exercise at least 4 times b). Create a buffer capable of storing 100 characters. Now after generating the characters, first store them in the buffer. Once the buffer is filled up, store all the elements in the file. Repeat the process until the total file size becomes approximately >10K.While reading read a while line, store it in buffer and once buffer gets filled up, display the whole buffer. Repeat the exercise at least 4 times with different size of buffer (50, 100, 150 …). Records the times. c). Do an analysis of the differences in times and submit it in class.
What happens if you free a pointer twice?
What is malloc calloc and realloc in c?
Write a simple code fragment that will check if a number is positive or negative.
Tell us the use of fflush() function in c language?
what is the function of pragma directive in c?
Explain a pre-processor and its advantages.
Explain how can a program be made to print the name of a source file where an error occurs?
What is preprocessor with example?