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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:10:58+00:00 2026-06-01T17:10:58+00:00

My problem is that the strcmp() functions makes the following problems: main.c:35: warning: passing

  • 0

My problem is that the strcmp() functions makes the following problems:

main.c:35: warning: passing argument 1 of ‘strcmp’ makes pointer from integer without a cast

While compiling and the following while running the program:

Segmentation fault: 11

I know what the errors means, I just don’t know any other way to do it…Have thought about using itoa() or sprintf(), but i need the checksum in hex so can’t see how I can accomplish that.

The code is as follows:

#include "checksum.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    char nmea[] ="$GPRMC,131637.000,A,5820.0658,N,00834.5652,E,0.00,,090911,,,A*7E";
    unsigned char checksum[] = "00";
    char data[82];
    int length = strlen(nmea);
    int k = 0;
    int i;
    unsigned char XOR;

    checksum[0] = nmea[(length-2)];
    checksum[1] = nmea[(length-1)];

    for(i=1;i < (length-3);i++){
        data[(i-1)] = nmea[i];
    }
    int dataLength = strlen(data);

    for (XOR = 0, i = 0; i < dataLength; i++)   //XORer for å finne checksum
        XOR ^= (unsigned char)data[i];

    printf("*******************************************************\n");
    printf("Calculating checksum...\n");

    printf("Read checksum: %s\n",checksum);
    printf("Read data: %s\n",data);
    printf("Calculated checksum: %X \n",XOR);

    if(strcmp(XOR,checksum) == 0){          //sammenligner checksumer.
        printf("Checksum: OK!\n");
        //return 1;
    }
    else{
        printf("Checksum: Mismatch!\n");
        //return 0;
    }

    printf("*******************************************************\n");
    //nmeachecksum(buf);
    return 0;
}

Any help is greatly appreciated!

  • 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-01T17:10:59+00:00Added an answer on June 1, 2026 at 5:10 pm
    char XOR[2] = { 0, 0 };
    

    And then just use XOR[0] everywhere.

    The above is just my no-segfault rewrite of what your code was actually trying to do.

    What it should do . . . the strcmp() is comparing binary text against a formatted version of the same value, so it won’t work. Your unsigned char XOR; (or perhaps an 8-bit <stdint.h> type) is about right. But compare this with == as a scalar instead of with strcmp().

    What you compare it to . . . you will need to turn your NMEA printable hex into a scalar operand suitable for == so use sscanf() or just open code the hex conversion.1


    1. Hex input conversion code examples are available in many stackoverflow answers.

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

Sidebar

Related Questions

I have this simple problem that gets an input from the user using a
One problem that I come across regularly and yet don't have a solution to
A problem that we need to solve regularly at my workplace is how to
The problem that I am having has to do with the need to keep
A problem that has frequently come up in my career is I have some
Simple problem that I can't figure out... How can I print a '%' character
The problem that I have is somehow very specific. I have to implement a
I have a problem that confuses my users, being that although an item is
This has been a problem that I haven't been able to figure out for
I have the problem that an specific step in Ant can only be executed

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.