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 1111223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:30:49+00:00 2026-05-17T02:30:49+00:00

i try to compare between 2 char* identical strings,but one of them contains a

  • 0

i try to compare between 2 char* identical strings,but one of them contains a null terminator at the end.
i’ve been looking through the internet and understood that it’s not recommendable to remove the null terminator char cause it will make the string unstable.
what other methods can i use?

the comparing function:

int StringCompare(const char* str1, const char* str2)  
{
    int size1 = strlen(str1), size2 = strlen(str2), min = 0, index =0;  
    bool bigger1 = true;  
    if(size1>size2)  
        min=size2;  
    else  
        min=size1;  
    for(index=0;index<min;index++)  
    {  
        if(str1[index]>str2[index])  
            return 1;  
        if(str1[index]<str2[index])  
            return (-1);  
    }  
    if(size1==size2)  
        return 0;  
    if(min==size1)  
        return (-1);  
    else  
        return 1;  
}    

thanks!

  • 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-05-17T02:30:50+00:00Added an answer on May 17, 2026 at 2:30 am

    You are using strlen which requires a null terminator at the end of the string. If one of the strings you pass doesn’t have a terminator, you are guaranteed to fail.

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

Sidebar

Related Questions

I try to compare Mnesia with more traditional databases. As I understand it tables
i try to compare two lists with each other: ListA (a1,a2,a3,...) ListB (b1,b2,b3,...) I
I have used a stacked bar chart (with coord_flip) to try to compare distributions
I try to get some website attribute (colour of the cell) and compare in
For example, I try to do something like this: - (BOOL)compare:(NSDecimal)leftOperand greaterThan:(NSDecimal)rightOperand { BOOL
Overview I'm looking to analyse the difference between two characters as part of a
I need to read in a file that contains 2 sentences to compare and
String child = C; Parent p = null; try { Class c1 = new
Hi I have a stored procedure which suppose to compare between 2 columns on
I'm trying to compare two millisecond values in Java. One from a calendar, and

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.