Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7838211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:02:10+00:00 2026-06-02T15:02:10+00:00

Edit: Changed title to reflect both methods in post. I’m trying to compare two

  • 0

Edit: Changed title to reflect both methods in post.

I’m trying to compare two strings in c language as below but for some reason it’s always printing that both strings are not equal

#include <stdio.h>
#include <string.h>


int main()
{
    /* A nice long string */

    char test[30]="hellow world";

    char test2[30];

    // to copy string from first array to second array

    strcpy(test2, test);



    /* now comparing two stering*/

    if(strcmp(test2, test))
       printf("strigs are equal  ");
    else

    printf("not equal  \n");

    printf("value of first string  is %s and second string is %s",test,test2);
    printf("length of string1 is %zu and other string is %zu ",strlen(test2),strlen(test2));



}

I’m always getting output as

not equal  
value of first string  is hellow world and second string is hellow worldlength of string1 is 12 and other string is 12 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:02:21+00:00Added an answer on June 2, 2026 at 3:02 pm

    Your problem is with how you’re using strcmp. strcmp returns 0 (which evaluates as false) when the strings are equal (and returns a positive number when the strings are “in order” and a negative number when they’re “out of order”).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: changed the title to fit the code below. I'm trying to retrieve a
EDIT: Changed title to actually be correct I'm trying to simulate a modal popup
EDIT: changed the title. I didn't know it at the time but this is
Edit: Changed question title from Does C# allow method overloading, PHP style (__call)? -
Note: The title of this was changed to better reflect the actual problem. I've
EDIT : Changed title from inheritance to composition. Left body of question unchanged. I'm
EDIT:I've changed the title, because the issue had nothing to do with IE image.load()
EDIT: I have changed the question as it was too localized and gained negative
Is there a way to know if TAdoQuery in Edit state was changed? Assuming
Edit: Read the lines in bold to find where I'm having problems. I changed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.