#include
void main()
{
char str1[10],str2[10];
int i=0;
int flag = 0;
printf("enter first string\n");
scanf("%s",str1);
printf("enter second string\n");
scanf("%s",str2);
while(str1[i]!='/0' && str2[i]!='/0')
{
if(str1[i]!=str2[i])
flag=1;
if(flag==1)
{
printf("not equal\n");
break;
}
if (flag==0)
{
printf("equal\n");
break;
}
}
}
i don't know ask someone else
nahi malum
Program below?!
bmbmbvjmgjmgj
No.
You can't. While a string is a character array, an array is not necessarily a string. Treating arrays as if they were strings simply to swap them is madness. The correct way to physically swap arrays A and B is to copy A to a new array, C, then copy B to A, then C to B. If the arrays are the same size this is not a problem. If they are different sizes, you can only swap them if they are dynamic (not static). This means you must reallocate them. To speed up the process, copy the smallest array to C, first. A much better approach would be to point at the two arrays and swap the pointers instead.
If the array is static you can simply point at the first element. For dynamic arrays you can allocate a contiguous block to a single pointer which can then be subdivided using a one-dimensional array of pointer to pointers, each of which points to a one-dimensional array of pointers, each of which points to a separate object within the array. For extremely large arrays, however, it is better to split the elements into separate one-dimensional arrays, by creating a one-dimensional array of pointer to pointers first, then allocating each of those pointers to a separate one-dimensional array of pointers, each of which points to a separate one-dimensional array of objects. Either way, you must destroy all the individual arrays in the reverse order of creation.
mystrcpy (char* dest, char* src) { while ((*dest++ = *src++) != '\0); }
performing string operation using pointers
you need strings to print any character(your name) this is not possible useing array:D
It is called strcmp, part of the standard run-time library. Returns 0 if the two strings are equals, non-zero otherwise.
Strings represented by the language character set (e.g., ASCII) are stored as null-terminated arrays of type char. Wide-character strings are stored as null-terminated arrays of type wchar_t. Other types are also available, such as char16 and char32 (for UTF16 and UTF32 encodings, respectively).