Foro de elhacker.net

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??
Código
  1. #include<conio.h>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4.  
  5. main()
  6. {
  7. int num1, num2, r;
  8. printf("Escribe 2 numeros y te diré los impares entre ellos\n");
  9. printf("Numero 1\n");
  10. scanf("%d",&num1);
  11. printf("Numero 2\n");
  12. scanf("%d",&num2);
  13. printf("Los impares son:\n");
  14.        if(num1%2==0)
  15.        {
  16.            for(r=num1+1;r<num2;r=r+2)
  17.            printf("%d\n",r);
  18.        }
  19.        if(num1%2!=0)
  20.        {
  21.            for(r=num1+2;r<num2;r=r+2)
  22.            printf("%d\n",r);
  23.        }
  24. system("pause");
  25. }
  26.  

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
Citar
Main 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
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
Citar
WG14/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
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