R4R
Right Place For Right Person TM

How to compare two strings without using the strcmp() function?

previous previous previous
Question:
How to compare two strings without using the strcmp() function?

Question:How to compare two strings without using the strcmp() function?


Answer
I have given you a example.In this we compare two strings str1 and str2 without using the strcmp() function. Example: #include <stdio.h> #include <string.h> void stringcompare(char str1[], char str2[]); int main() { char string1[10],string2[10]; printf("\nEnter first String:"); scanf("%s",string1); printf("\nEnter second String:"); scanf("%s",string2); stringcompare(string1,string2); return 0; } void stringcompare(char *str1, char *str2) { int i,j; for(i=0;str1[i]!='\0';i++) { for(j=0;str2[j]!='\0';j++) { if(str1[i] == str2[j]) continue; } } if (i==j) { printf("String str1:%s and str2:%s are EQUAL\n",str1,str2); } else printf("String str1:%s and str2:%s are NOT EQUAL\n",str1,str2); }

By:Vivek Kr. Agarwal
Date:

How to compare two strings without using the strcmp() function?

Post Your Answers


User Name:
Answers:

Related Links

  1. How to access or modify the constt variable in C ?
  2. What is an volatile variable?
  3. How the processor registers can be used in C?
  4. IF **p and &(*p) are same, than tell how?
  5. Can you write function similar to printf()?
  6. How to use functions fseek(), freed(), fwrite() and ftell()?
  7. What do you understand about datatype?
  8. What are the data type modifiers?
  9. what are the constants?Explain in brief?
  10. How to differentiate b/n definition and declaration?
  11. How to define their types of variables and initialize them?
  12. What is type casting?Explain it with an example?
  13. What are the Array?How to define and declare them?
  14. What are the Array Indexing?explain.
  15. What do you understand about String?Explain it.
  16. What are the reserved Keywords?Explain it.
  17. What are the ANSI reserved names in C?
  18. What are the pointers?How to declare them?
  19. What are the Indirection?Explain with an example?
  20. What are the Function Pointer?Explain with an example?
  21. What are the Bit Operators?
  22. What are the External Variables?
  23. How to define structure in C?
  24. How do u understand about structures of arrays?
  25. How do you define offsetof() Macro?
  26. What the use of malloc() function?
  27. What are the different types of malloc() function in C?
  28. What is the use of calloc() function?
  29. What are the different type of calloc() function?
  30. How to use free() function?
  31. How to differentiate local memory and global memory?
  32. What is the significance of disk files?
  33. What are the Text Files and Binary Files?
  34. What are the temporary disk files?How to create them?
  35. What are the stream files?
  36. What are the stdin and stdout file?
  37. What is the stdaux file?
  38. What do you understand about Direct port I/O?
  39. What is the data management?Also define Sorting, merging and purging, Indexed files?
  40. What are the Linked List?
  41. What is the Double LinkedList?
  42. What is the difference b/n Linear search and Binary search?
  43. What do you understand about B-Tree?
  44. What is Thrashing?
  45. What is a pragma?
  46. What is the difference between the Heap and the Stack?
  47. Why n++ executes faster than n+1?
  48. What is the difference b/n a linker and linkage?
  49. What is the difference b/n run time binding and compile time binding?
  50. Write algorithm to reverse a singly linked list.

Question:How to compare two strings without using the strcmp() function?

Back Home Next

New Updates

Topics

Topics

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R