Hola gente! Estoy aprendiendo C y tenia que hacer un cronometro con el bucle for. El tema es que, en windows me anda pero en mi Ubuntu, con Geany compila pero me sale la consola y nada. Cual es mi error?
#include <stdio.h>
#include <unistd.h>
int main ()
{
int h, m, s, x;
x = 1000;
for (h=0;h<60;h++) {
for (m=0;m<60;m++) {
for (s=0;s<60;s++) {
printf ("%i:%i:%i\r", h, m, s);
sleep (x);
}
}
}
}
Intoduce antes de cerrar el main un getch y return.
} //Cierre del for
} //Cierre del for
} //Cierre del for
getch();
return 0;
} // Cierre del main
Gracias por responder :) pero me sale esto en consola que sera ?
./geany_run_script.sh: 5: ./geany_run_script.sh: ./bucles anidados: not found
------------------
(program exited with code: 127)
Press return to continue
You only compiled your source file, but didn't build your application, meaning the linking was not done and the executable was not created. Use the "build" sub-menu from the "build" menu (default shortcut is F9 if I recall correctly) and try again.
No tienes permitido ver los links.
Registrarse o Entrar a mi cuenta
You only compiled your source file, but didn't build your application, meaning the linking was not done and the executable was not created. Use the "build" sub-menu from the "build" menu (default shortcut is F9 if I recall correctly) and try again.
Tenias razon. Ya pude compilar sin ningun error. Pero me sigue sin funcionar el programa. Me muestra con el printf, los valores 0:0:0 pero no sigue.. En windows me anda bien.
Gracias de todos modos:)
Prueba esto
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
int main ()
{
int h, m, s, x;
x = 1;
for (h=0;h<60;h++)
{
for (m=0;m<60;m++)
{
for (s=0;s<60;s++)
{
printf ("%i:%i:%i\n", h, m, s);
sleep (x);
}
}
}
}
Se compila con "gcc archivo.c" y se ejecuta con "./a.out" (supongo que ya lo sabrás)
No tienes permitido ver los links.
Registrarse o Entrar a mi cuenta
Prueba esto
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
int main ()
{
int h, m, s, x;
x = 1;
for (h=0;h<60;h++)
{
for (m=0;m<60;m++)
{
for (s=0;s<60;s++)
{
printf ("%i:%i:%i\n", h, m, s);
sleep (x);
}
}
}
}
Se compila con "gcc archivo.c" y se ejecuta con "./a.out" (supongo que ya lo sabrás)
Ahi esta ahora si me anda gracias. Con el \n en el printf. Porque no funciona el \r ?