What is the error in this Code: [closed]

2

I am trying to compile this code, use the C head but this is returning me errors

#include <stdio.h>

    void go_south_east(int* lat, int* lon)
    {
        *lat = *lat -1;
        *lon = *lon - 1;

    }

    int main()
    {
        int latitude = 32;
        int logitude = -64;
        go_south_east(&latitude, &longitude);
        printf("Avast! Now at: [%i, %i]\n", latitude, longitude);
      return 0;

    }

Error:

root@kali:~# gcc testmains.c -o testmains testmains.c: In function ‘main’: testmains.c:14:28: error: ‘longitude’ undeclared (first use in this function) testmains.c:14:28: note: each undeclared identifier is reported only once for each function it appears in 
    
asked by anonymous 07.11.2014 / 12:27

2 answers

4

Friend, edit variable name:

int logitude = -64;
go_south_east(&latitude, &longitude);

When declaring an 'n' is missing in the longitude.

    
07.11.2014 / 12:47
9

In a Quick Test you will see the following error messages:

prog.c: In function ‘main’:
prog.c:14:35: error: ‘longitude’ undeclared (first use in this function)
         go_south_east(&latitude, &longitude);
                                   ^
prog.c:14:35: note: each undeclared identifier is reported only once for each function it appears in
prog.c:13:13: warning: unused variable ‘logitude’ [-Wunused-variable]
         int logitude = -64;
         ^

That is, the variable longitude was not declared, and we have another variable logitude that is not used.

I guess you just spelled the name of this variable wrong. Correcting this the code compiles and executes.

    
07.11.2014 / 12:36