Test Foro de elhacker.net SMF 2.1

Programación => Programación C/C++ => Mensaje iniciado por: Franco2410 en 18 Septiembre 2016, 02:58 AM

Título: [Error] ld returned 1 exit status
Publicado por: Franco2410 en 18 Septiembre 2016, 02:58 AM
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


Título: Re: [Error] ld returned 1 exit status
Publicado por: engel lex en 18 Septiembre 2016, 03:59 AM
Main debe de ser una funcion que retorne int y al finalizar debe retornar 0
Título: Re: [Error] ld returned 1 exit status
Publicado por: HardForo en 21 Septiembre 2016, 18:09 PM
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.
Título: Re: [Error] ld returned 1 exit status
Publicado por: MAFUS en 21 Septiembre 2016, 22:50 PM
A partir de C99 el return de main es opcional, se devolverá 0 por defecto.
Título: Re: [Error] ld returned 1 exit status
Publicado por: dato000 en 22 Septiembre 2016, 04:24 AM
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.
Título: Re: [Error] ld returned 1 exit status
Publicado por: MAFUS en 22 Septiembre 2016, 08:54 AM
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.

Título: Re: [Error] ld returned 1 exit status
Publicado por: 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
Título: Re: [Error] ld returned 1 exit status
Publicado por: engel lex en 9 Octubre 2016, 18:41 PM
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