vendredi 2 janvier 2015

Different variable address between g++ -std=c++11 and visual studio 2013

When running this code



#include <cstdlib>
#include <cstdio>

int main() {
char b;
char c;
printf("%d\n", &b - &c);
return 0;
}


I got 12 using Microsoft visual studio 2013, and -1 using g++ -std=c++11 under Ubuntu 14.04. What is the reason for this difference?


Or did I make a mistake when testing variables' memory addresses?


Aucun commentaire:

Enregistrer un commentaire