jpedro7 Posted December 21, 2007 at 07:51 PM Report Share #155635 Posted December 21, 2007 at 07:51 PM Quando converto duas strings para inteiros o resultado aparece errado porquê ? código: int i, x, a=0, c, d; char var_i[2], var_f[2]; printf("\nQual a 1ª linha a eliminar exemplo(1) \n"); scanf ("%s", &var_i); printf("\nQual a ultima linha a eliminar exemplo(2)\n"); scanf ("%s", &var_f); c = atoi(var_i); d = atoi(var_f); printf("prim...%d \n", &c); printf("seg...%d \n", &d); No teste preenchi no primeiro printf coloquei o valor 2 e no segundo printf também o valor 2 e o resultado foi este: prim...1244204 seg...1244192 Alguem me pode ajudar ? Obrigado Link to comment Share on other sites More sharing options...
Rui Carlos Posted December 21, 2007 at 08:03 PM Report Share #155637 Posted December 21, 2007 at 08:03 PM Nos printfs não se usa o &. Estás a imprimir o endereço de memória das variáveis e não o seu valor. Rui Carlos Gonçalves Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now