Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

I want to know why this program is executing output like this " -111 111 0" briefly .

Status
Not open for further replies.

praveenkumar450

Newbie level 5
Joined
Jul 2, 2014
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Hyderabad, Andhra Pradesh, India
Activity points
55
I want to know why this program is executing output like this " -111 111 0" briefly .

Code:
#include <stdio.h>
#include <string.h>
int main() {
  char string1[20];
  char string2[20];

  strcpy(string1, "Hello");
  strcpy(string2, "Hellooo");
  printf("Return Value is : %d\n", strcmp( string1, string2));

  strcpy(string1, "Hellooooo");
  strcpy(string2, "Hello");
  printf("Return Value is : %d\n", strcmp( string1, string2));

  strcpy(string1, "Hellooo");
  strcpy(string2, "Hellooo");
  printf("Return Value is : %d\n", strcmp( string1, string2));

  return 0;
}
 

Re: I want to know why this program is executing output like this " -111 111 0" brief

strcmp() returned values are as follows:
if Return value if < 0 then it indicates str1 is less than str2

if Return value if > 0 then it indicates str2 is less than str1

if Return value if = 0 then it indicates str1 is equal to str2
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top