Ayuda cuando quiero compilar el siguiente programa en C me aparece el error [Error] ld returned 1 exit status, como puedo corregirlo y hacer que corra??
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
main()
{
int num1, num2, r;
printf("Escribe 2 numeros y te diré los impares entre ellos\n");
printf("Numero 1\n");
scanf("%d",&num1);
printf("Numero 2\n");
scanf("%d",&num2);
printf("Los impares son:\n");
if(num1%2==0)
{
for(r=num1+1;r<num2;r=r+2)
printf("%d\n",r);
}
if(num1%2!=0)
{
for(r=num1+2;r<num2;r=r+2)
printf("%d\n",r);
}
system("pause");
}
Mod: los codigos deben ir en etiquetas geshi
Main debe de ser una funcion que retorne int y al finalizar debe retornar 0
CitarMain debe de ser una funcion que retorne int y al finalizar debe retornar 0
No creo tenga nada que ver, si no se especifica un valor de retorno retorna 0 (al menos con GCC)
Mas bien... por algun motivo explota justo antes de salir.
A partir de C99 el return de main es opcional, se devolverá 0 por defecto.
Cita de: MAFUS en 21 Septiembre 2016, 22:50 PM
A partir de C99 el return de main es opcional, se devolverá 0 por defecto.
depende del compilador.
CitarWG14/N1256 Committee Draft — Septermber 7, 2007 ISO/IEC 9899:TC3
5.1.2.2.3 Program termination
1 If the return type of the main function is a type compatible with int, a return from the initial call to the main function is equivalent to calling the exit function with the value
returned by the main function as its argument;10) reaching the } that terminates the main function returns a value of 0. If the return type is not compatible with int, the termination status returned to the host environment is unspecified.
Forward references: definition of terms (7.1.1), the exit function (7.20.4.3).
Del borrador del estandar N1256.
Intentas ejecutar el programa como administrador
yo tenia es mismo problema y solo tuve que ejecutarlo como administrador
Cita de: erick28alex en 9 Octubre 2016, 18:38 PM
Intentas ejecutar el programa como administrador
yo tenia es mismo problema y solo tuve que ejecutarlo como administrador
si ni requiere permisos de administrador, no se debe ejecutar con ellos, si tu necesitas hacer esto probablemente tengas un error en alguna configuración