I'm trying to make some basic number incrementation but I'm getting some weird garbage values. (this works in C# but not in C). Could someone tell me why this is not working?
while (1)
{
int command = 0;
printf ("Action: ");
scanf ("%d", &command);
int countX, countY, countZ = 0;
if (command == 1)
{
countX++;
}
if (command == 2)
{
countY++;
}
if (command == 3)
{
countZ++;
}
if (command == 0)
{
printf ("x: %d, y: %d, z: %d", countX, countY, countZ);
}
}
Aucun commentaire:
Enregistrer un commentaire