elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  C ¿Windows?
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 Ir Abajo Respuesta Imprimir
Autor Tema: C ¿Windows?  (Leído 3,911 veces)
x4cks

Desconectado Desconectado

Mensajes: 8


Ver Perfil
C ¿Windows?
« en: 6 Junio 2011, 02:17 am »

Hi brothers , vengo a decirles algo importante que quisa les dee mas ganas de aprender C

Nose porque hay muchos usuarios que se la pasan estudiando c y siempre se orientan para windows , ¿Por qué? , yo desde que empece c siempre he trabajado en gnu/linux nunca me gusto trabajarlo en windows.

Ejemplos de sockets en GNU/Linux y en Windows:
Código:
/**********************************************************************
 * client.c --- Demonstrate a simple client.
 * Tom Kelliher
 *
 * This program will connect to a simple iterative server and exchange
 * messages.  The single command line argument is the server's hostname.
 * The server is expected to be accepting connection requests from
 * SERVER_PORT.
 *
 * The same message is sent three times over separate connections,
 * demonstrating that different ephemeral ports are used for each
 * connection.
 **********************************************************************/


#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>


#define DATA "The sea is calm tonight, the tide is full . . ."
#define SERVER_PORT 5001
#define BUFFER_SIZE 1024


/* prototypes */
void die(const char *);
void pdie(const char *);


/**********************************************************************
 * main
 **********************************************************************/

int main(int argc, char *argv[]) {

   int sock;   /* fd for socket connection */
   struct sockaddr_in server;   /* Socket info. for server */
   struct sockaddr_in client;   /* Socket info. about us */
   int clientLen;   /* Length of client socket struct. */
   struct hostent *hp;   /* Return value from gethostbyname() */
   char buf[BUFFER_SIZE];   /* Received data buffer */
   int i;   /* loop counter */

   if (argc != 2)
      die("Usage: client hostname");

   /* Open 3 sockets and send same message each time. */

   for (i = 0; i < 3; ++i)
   {
      /* Open a socket --- not bound yet. */
      /* Internet TCP type. */
      if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
         pdie("Opening stream socket");
      
      /* Prepare to connect to server. */
      bzero((char *) &server, sizeof(server));
      server.sin_family = AF_INET;
      if ((hp = gethostbyname(argv[1])) == NULL) {
         sprintf(buf, "%s: unknown host\n", argv[1]);
         die(buf);
      }
      bcopy(hp->h_addr, &server.sin_addr, hp->h_length);
      server.sin_port = htons((u_short) SERVER_PORT);
      
      /* Try to connect */
      if (connect(sock, (struct sockaddr *) &server, sizeof(server)) < 0)
         pdie("Connecting stream socket");
      
      /* Determine what port client's using. */
      clientLen = sizeof(client);
      if (getsockname(sock, (struct sockaddr *) &client, &clientLen))
         pdie("Getting socket name");
      
      if (clientLen != sizeof(client))
         die("getsockname() overwrote name structure");
      
      printf("Client socket has port %hu\n", ntohs(client.sin_port));
      
      /* Write out message. */
      if (write(sock, DATA, sizeof(DATA)) < 0)
         pdie("Writing on stream socket");
      
      /* Prepare our buffer for a read and then read. */
      bzero(buf, sizeof(buf));
      if (read(sock, buf, BUFFER_SIZE) < 0)
         pdie("Reading stream message");
      
      printf("C: %s\n", buf);
      
      /* Close this connection. */
      close(sock);
   }

   exit(0);

}


/**********************************************************************
 * pdie --- Call perror() to figure out what's going on and die.
 **********************************************************************/

void pdie(const char *mesg) {

   perror(mesg);
   exit(1);
}


/**********************************************************************
 * die --- Print a message and die.
 **********************************************************************/

void die(const char *mesg) {

   fputs(mesg, stderr);
   fputc('\n', stderr);
   exit(1);
}



http://msdn.microsoft.com/en-us/library/ms741394%28v=vs.85%29.aspx no encontre otro.

Windows?
Por que aprender c orientado a windows?
que veneficio hay?
Linux/unix!
Tiene muchos veneficios , me gusta mas su sintaxis , aprender c usando linux/unix es lo mejor , imaginate que no sepas para que sirve tal libreria o tal funcion , primero no sabes usar esa libreria pero luego aprendes 100 librerias mas , ¿como?
Use the ManPage wiki
Código:
Man pages (short for manual pages) are the extensive documentation that comes preinstalled with almost all substantial Unix and Unix-like operating systems. The Unix command used to display them is man. Each page is a self-contained document.
Para usar simplemente lo haces asi:
man stdio.h ¿Por que digo k aprendes a usar otras librerias o funciones?
al final del man tienen unas referencias , yo todo lo que se de C/C++ lo aprendi usando man y practicando mucho , y algunos libros pero mas el man.


Código:
NAME

    stdio.h - include definitions for standard buffered input/output

SYNOPSIS

    #include <stdio.h>

DESCRIPTION

    The <stdio.h> header includes the following kinds of definitions:

        Constants subsection of stdio.h(4)
        Data Types subsection of stdio.h(4)
        External Variables subsection of stdio.h(4)
        Function Prototypes subsection of stdio.h(4)

    Inclusion of the <stdio.h> header may make visible all symbols from the <stddef.h> header.
    Constants

    The following macro names are defined as positive integral constant expressions.

    BUFSIZ
        Size of <stdio.h> buffers.
    FILENAME_MAX
        Maximum size in bytes of the longest file name string that the system guarantees can be opened.
    FOPEN_MAX
        Number of streams that the system guarantees can be open simultaneously. The value will be at least eight.
    _IOFBF
        Input and output fully buffered.
    _IOLBF
        Input and output line buffered.
    _IONBF
        Input and output unbuffered.
    L_ctermid
        Maximum size of character array to hold ctermid() output.
    L_tmpnam
        Maximum size of character array to hold tmpnam() output.
    SEEK_CUR
        Seek relative to current position.
    SEEK_END
        Seek relative to end-of-file.
    SEEK_SET
        Seek relative to start-of-file.
    TMP_MAX
        Minimum number of unique file names generated by tmpnam(). Maximum number of times an application can call tmpnam() reliably. The value of TMP_MAX will be at least 10,000.

    The following defined constant is scheduled to be withdrawn from a future version of the Single UNIX Specification:

    L_cuserid
        Maximum size of character array to hold cuserid() output.

    Macros

    The following macro name is defined as a negative integral constant expression:

    EOF
        End-of-file return value.

    The following macro name is defined as a null pointer constant:

    NULL
        Null pointer.

    The following macro name is defined as a string constant:

    P_tmpdir
        Default directory prefix for tempnam().

    The following macro names are defined as expressions of type pointer to FILE:

    stderr
        Standard error output stream.
    stdin
        Standard input stream.
    stdout
        Standard output stream.

    Data Types

    The following data types are defined through typedef:

    FILE
        A structure containing information about a file.
    fpos_t
        Type containing all information needed to specify uniquely every position within a file.
    size_t
        Unsigned integral type of the result of the sizeof operator.
    va_list
        Defined for variables used to traverse a variable argument list, as described in the stdarg.h(4) reference page.

    External Variables

    The following are defined as external variables. These external variables are scheduled to be withdrawn from a future version of the Single UNIX Specification.

    extern char *optarg
    extern int opterr
    extern int optind
    extern int optopt

    These variables are also defined in the <unistd.h> header.
    Function Prototypes

    The following are declared as functions and may also be defined as macros. An application programmer can use an #undef statement to remove the macro definition and ensure that the program uses the actual function.

    void clearerr(FILE *stream);

    char *ctermid(char *s);

    int fclose(FILE *stream);

    FILE *fdopen(int fildes, const char * mode);

    int feof(FILE *stream);

    int ferror(FILE *stream);

    int fflush(FILE *stream);

    int fgetc(FILE *stream);

    int fgetpos(FILE *stream, fpos_t *pos);

    char *fgets(char *s, int n, FILE *stream);

    int fileno(FILE *stream);

    FILE *fopen(const char *filename, const char *mode);

    int fprintf(FILE *stream, const char *format, ...);

    int fputc(int c, FILE *stream);

    int fputs(const char *s, FILE *stream);

    size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);
            

    FILE *freopen(const char *filename, const char *mode,
            FILE *stream);

    int fscanf(FILE *stream, const char *format, ...);

    int fseek(FILE *stream, long int offset, int whence);

    int fsetpos(FILE *stream, const fpos_t *pos);

    long int ftell(FILE *stream);

    size_t fwrite(const void *ptr, size_t size, size_t nitems,
            FILE *stream);

    int getc(FILE *stream);

    int getchar(void);

    char *gets(char *s);

    int getw(FILE *stream);

    int pclose(FILE *stream);

    void perror(const char *s);

    FILE *popen(const char *command, const char *mode);

    int printf(const char *format, ...);

    int putc(int c, FILE *stream);

    int putchar(int c);

    int puts(const char *s);

    int putw(int w, FILE *stream);

    int remove(const char *path);

    int rename(const char *old, const char *new);

    void rewind(FILE *stream);

    int scanf(const char *format, ...);

    void setbuf(FILE *stream, char *buf);

    int setvbuf(FILE *stream, char *buf, int type, size_t size);

    int sprintf(char *s, const char *format, ...);

    int sscanf(const char *s, const char *format, int ...);

    char *tempnam(const char *dir, const char *pfx);

    FILE *tmpfile(void);

    char *tmpnam(char *s);

    int ungetc(int c, FILE *stream);

    int vfprintf(FILE *stream, const char *format, va_list ap);

    int vprintf(const char *format, va_list ap);

    int vsprintf(char *s, const char *format, va_list ap);

    The following declared functions are scheduled to be withdrawn from a future version of the Single UNIX Specification:

    char *cuserid(char *s);

    int getopt(int argc, const char *argv[], const char *optstring);

SEE ALSO

    clearerr(3), ctermid(3), cuserid(3), fclose(3), fdopen(3), feof(3), ferror(3), fflush(3), fgetc(3), fgetpos(3), fgets(3), fileno(3), fopen(3), fputc(3), fputs(3), fread(3), freopen(3), fseek(3), fsetpos(3), ftell(3), fwrite(3), getc(3), getchar(3), getopt(3), gets(3), getw(3), getwchar(3), pclose(3), perror(3), popen(3), printf(3), putc(3), putchar(3), puts(3), putw(3), putwchar(3), remove(3), rename(2), rewind(3), scanf(3), setbuf(3), setvbuf(3), sscanf(3), system(3), tempnam(3), tmpfile(3), tmpnam(3), ungetc(3), vprintf(3), stdarg.h(4), stddef.h(4), systypes.h(4), stdin(5), xshstdiostr(5)

Lo ven  , todas esas referencias?




Espero que reflexionen y opinen que es mejor trabajar en unix/linux o windows?

Linux rlZ!

PD: Yo trabajo en windows en c a nivel basico porque todo es casi igual pero despues me voy mas para el lado de gnu/linux ,para todos aquellos que quieran aprender c les recomiendo usar el kernel gnu/linux. ¿APIS WINDOWS ajajaja? - nunca las estudie ni siquiera me interesan.
GTK obvio que si

Corriganme si es que me equivoco.
Saludos


« Última modificación: 6 Junio 2011, 02:37 am por x4cks » En línea

Akai


Desconectado Desconectado

Mensajes: 823



Ver Perfil
Re: C ¿Windows?
« Respuesta #1 en: 6 Junio 2011, 10:04 am »

Si a ti no te interesa, perfecto, en parte comparto tu opinión.

En cambio hay gente que prefiere orientar su conocimiento al área en la que considera que está /estará trabajando frecuentemente o por otro lado lo enfoca por una situación de marketshare en PC de escritorio, o dios sabe qué.

FLAME sin sentido. Si quieres hacer un tutorial sobre sockets en A o B plataforma, será bienvenido. Una comparación con un tono académico entre ambas, también. Esta clase de flame, no.


En línea

Khronos14


Desconectado Desconectado

Mensajes: 443


A lie is a lie


Ver Perfil WWW
Re: C ¿Windows?
« Respuesta #2 en: 6 Junio 2011, 14:31 pm »

A parte de lo que dijo Akai, aprende a escribir como dios manda.

"que veneficio hay?" Aquí me sangraron los ojos...
En línea

x4cks

Desconectado Desconectado

Mensajes: 8


Ver Perfil
Re: C ¿Windows?
« Respuesta #3 en: 6 Junio 2011, 15:44 pm »

A parte de lo que dijo Akai, aprende a escribir como dios manda.

"que veneficio hay?" Aquí me sangraron los ojos...

Perdon alejandro magno , que no sepa escribir correctamente , usted me podria dar una clase ?
¬¬ si vas a dar un comentario como ese mejor no lo hagas.

Akai gracias por tu comentario.
« Última modificación: 6 Junio 2011, 15:48 pm por x4cks » En línea

d(-_-)b


Desconectado Desconectado

Mensajes: 1.331



Ver Perfil WWW
Re: C ¿Windows?
« Respuesta #4 en: 6 Junio 2011, 15:53 pm »

Citar
Nose porque hay muchos usuarios que se la pasan estudiando c y siempre se orientan para windows , ¿Por qué?

Programamos en Windows porque nos gusta, pero tampoco temenos problemas para programar en Linux.

Citar
yo desde que empece c siempre he trabajado en gnu/linux nunca me gusto trabajarlo en windows.

Bien esa es una razon, a muchos no les gustan trabajar en linux.

Citar
¿Por qué?

Una respuesta mas directa es que cada quien programa en el OS que le apetezca, quieres que los usuarios de windows que conocen C programen para linux, pero tu no quieres ni te interesa windows.

Que mas da en que sistema operativo programen, la idea es programar.

Citar
¿APIS WINDOWS ajajaja? - nunca las estudie ni siquiera me interesan

Es una lastima que no conozca el potencial de las APIS de Windows, Si quieres ser un programador, cambia tu forma de persar.

Citar
Espero que reflexionen y opinen que es mejor trabajar en unix/linux o windows

Segun tu experiencia Linux. Ninguna plataforma es mejor que otra.

Suerte.

saludos...
« Última modificación: 6 Junio 2011, 16:08 pm por Slow V.S. » En línea

Max 400; caracteres restantes: 366
x4cks

Desconectado Desconectado

Mensajes: 8


Ver Perfil
Re: C ¿Windows?
« Respuesta #5 en: 6 Junio 2011, 17:14 pm »

conozco las apis , me las estudie hasta la mitad y nunca mas lo vi despues me olvide todo , porque nunca uso windows siempre tengo gnu/linux , en mi computadora no existe windows no lo tengo siquiera instalado.

En fin , lo que queria hacer es debate yo sigo pensando que trabajar en gnu/linux es mucho mejor y aprendes mas rapido , es mas , es mucho mas comodo.

yo trabajo con gtk que es multiplataforma.
« Última modificación: 6 Junio 2011, 17:16 pm por x4cks » En línea

Queta

Desconectado Desconectado

Mensajes: 267



Ver Perfil
Re: C ¿Windows?
« Respuesta #6 en: 6 Junio 2011, 21:54 pm »

¿APIS WINDOWS ajajaja? - nunca las estudie ni siquiera me interesan.

conozco las apis , me las estudie hasta la mitad

Me encanta tu coherencia ::). Supongo que la gente ya verá tu gran madurez al criticar Windows porque sí; mientras tanto de dejo con tu Linux y tu 1,82% de cuota de mercado (preveo que me responderás con lo de los servidores Web).

PD: se me olvidaba, en Linux tampoco hay malware, ¿no :silbar:?
« Última modificación: 6 Junio 2011, 22:01 pm por Queta » En línea

"Intenta no volverte un hombre de éxito, sino volverte un hombre de valor." Albert Einstein.
Oblivi0n


Desconectado Desconectado

Mensajes: 392

Odio las ranas.


Ver Perfil
Re: C ¿Windows?
« Respuesta #7 en: 6 Junio 2011, 22:16 pm »

Como puedes decir que algo es "mejor" cuando, según tu, ni siquiera te has molestado en mirarlo?

Me parece que te has querido creer el "super hacker" diciendo que para ti solo existe GNU/Linux... 

P.D : Te contesto desde un ordenador con Debian... y programando para debian.... para que no pienses que soy un windows-fanboy :)
En línea

d(-_-)b


Desconectado Desconectado

Mensajes: 1.331



Ver Perfil WWW
Re: C ¿Windows?
« Respuesta #8 en: 6 Junio 2011, 22:38 pm »

conozco las apis , me las estudie hasta la mitad.

Osea te conocías la API'S de Windows en un 50%, Alucino, ningún programador se expresaría de esa forma, al menos los que conozco, ni yo mismo que juego con las API'S, ni le doy porcentajes a mis conocimientos, es absurdo.

yo sigo pensando que trabajar en gnu/linux es mucho mejor y aprendes mas rapido , es mas, es mucho mas comodo.

Volvemos a lo mismo, No hay razón para pensar que trabajar en este u otro es mejor, solo porque uno es de pago y el otro gratis. ¿Porque es mejor, solo porque te guste mas? pues bien, eso es bueno, para trabajar bien hay que hacerlo en el entorno que mas te guste, no significa que sea mejor que otro.

Y eso de que se aprende mas rápido también es una tontería, para aprender sea lo que sea, se exige por parte de uno mismo, esfuerzo, paciencia, buen método de aprendizaje, gamas de aprender, creatividad, etc...

En cuando a la comodidad, todo depende de uno mismo, que es mas cómodo, a la hora de trabajar ¿Un portátil o un PC sobremesa?, algunos les resulta mejor un portátil, por la movilidad, cosa que nos gusta a todo, pero en cuanto a trabar, nada mejor que un PC sobremesa, por muchas razones, etc..

Repito en cuando a que es mas cómodo o no, eso es cosa de cada uno, con el ejemplo que te expuse, cada uno elige lo que le resulte mejor.

Me párese que te quedara solo con tu debate.

saludos...
« Última modificación: 6 Junio 2011, 22:44 pm por Slow V.S. » En línea

Max 400; caracteres restantes: 366
Khronos14


Desconectado Desconectado

Mensajes: 443


A lie is a lie


Ver Perfil WWW
Re: C ¿Windows?
« Respuesta #9 en: 6 Junio 2011, 22:44 pm »

Perdon alejandro magno , que no sepa escribir correctamente , usted me podria dar una clase ?
¬¬ si vas a dar un comentario como ese mejor no lo hagas.

Akai gracias por tu comentario.

Si no sabes expresarte, la gente no te va a tomar en serio y muchas veces va a pasar de ti.

El fallo de programar en GNU/Linux es el entorno de desarrollo, ninguno le llega a la suela del zapato al Visual Studio, Delphi o C++ Builder.. Bueno, está MonoDevelop, pero aún le queda mucho que madurar..

PD: Te escribo desde mi Debian Squeeze..

Saludos.
En línea

Páginas: [1] 2 Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines