Home » C Programs » String Compare in C

String Compare in C

A pointer is a variable whose value is the address of another variable, the memory location’s direct address. The act of comparing two or more items by deciding the appropriate, comparable characteristics of each item is referred to as comparison.

Pointer in C Program

A pointer is a variable whose value is the address of another variable, i.e. the memory location’s direct address. A pointer, like any variable or constant, must be declared before it can be used to store any variable address. 

A variable that stores the address of another variable is known as a pointer. In contrast to other variables that hold values of a specific type, a pointer variable holds the address of a variable. In this program we used pointer to execute the string compare program in c

Int Pointer Size in C

On any 64-bit C/C++ compiler, the size of a pointer should be 8 bytes, but the same is not true for the size of an int. On 64-bit machines, “int” variables are still 32 bits wide in many programming environments for C and C-derived languages, but long integers and pointers are 64 bits wide. 

Float Pointer Size in C

The data type of the pointer and the variable must match; an int pointer can hold the address of an int variable, and a float pointer can hold the address of a float variable.

If Else Method in C

In C, the if-else statement is used to perform operations based on a specific condition. If and only if the given condition is true, the operations specified in the if block are carried out. 

String Compare in C

//string compare in c
#include<stdio.h>
int main()
{
int *ptrA;
float *ptrB;
ptrA = (int *)1000;
ptrB = (float *)2000;
if(ptrB > ptrA)
printf("Pointer B is greater than pointer A");
return(0);
}

Output 

Pointer B is greater than Pointer A