Find Jobs
Hire Freelancers

CSV Reader in C programming

$20-25 USD

Cerrado
Publicado hace más de 15 años

$20-25 USD

Pagado a la entrega
I have the start of a simple CSV C program, that reads the file, parses it, then displays it. The code is 80% done but there is a litte bit of code that needs to be added to read the file and there may be other errors. I would like someone to finish the program so it works without errors. ## Deliverables This is the code I currently have: #include <stdio.h> #include "stdafx.h" int main(int argc, char ** argv){ ? int c; ? FILE * fp; ? if(argc < 2){ ? ? ? printf("Usage:\n\t%s filename\n",argv[0]); ? ? ? return -1; ? } ? if((fp = fopen(argv[1],"rb")) == NULL){ ? ? ? printf("can't open %s\n",argv[1]); ? ? ? return -2; ? } ? while((c = fgetc(fp)) != EOF){ #define MAX_LINE_LEN? ? 1024*512? // 1/2 mega byte, should be more than sufficient */ ? ? ? char line[MAX_LINE_LEN]; ? ? int len=0; ? ? int cnt_of_fields=0; ? ? char *p; ? ? while( (c=GET_A_CHAR_FROM_FILE(fp))!=EOF){ ? ? ? ? ? ? ? ? ? ? switch(c) ? ? ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? case '"': ? ? ? ? ? ? ? ? ? ? case '\'': ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // parse a quoted string, ignore it for now */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? case ',': ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ++cnt_of_fields; // a comma signal end of previous field and begining of next fields */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? line[len++]='\0'; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if(len==MAX_LINE_LEN){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? fprintf(stderr, "Line too long\n"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? exit(-1); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? case '\n': ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ++cnt_of_fields; // a EOL is end of record, and at the same time end of field */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? line[len++]='\0'; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // make a copy of the line in the heap, note strdup or strcpy won't work in our case */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? p = (char *)malloc(len); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? memcpy(p, line, len); // now all the fields in the record are stored in p[ ] */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? add_a_record( p ); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? default: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? line[len++] = c; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if(len==MAX_LINE_LEN){ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? fprintf(stderr, "Line too long\n"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? exit(-1); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? } ? ? ? printf( "%s", line ); ? } ? fclose(fp); ? return 0; }
ID del proyecto: 3631216

Información sobre el proyecto

47 propuestas
Proyecto remoto
Activo hace 15 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos
47 freelancers están ofertando un promedio de $14 USD por este trabajo
Avatar del usuario
See private message.
$17 USD en 3 días
4,9 (671 comentarios)
7,7
7,7
Avatar del usuario
See private message.
$21,25 USD en 3 días
4,8 (441 comentarios)
7,4
7,4
Avatar del usuario
See private message.
$21,25 USD en 3 días
4,9 (59 comentarios)
5,8
5,8
Avatar del usuario
See private message.
$20,40 USD en 3 días
5,0 (6 comentarios)
5,4
5,4
Avatar del usuario
See private message.
$21,25 USD en 3 días
5,0 (52 comentarios)
5,5
5,5
Avatar del usuario
See private message.
$17 USD en 3 días
4,8 (26 comentarios)
5,3
5,3
Avatar del usuario
See private message.
$21,25 USD en 3 días
5,0 (28 comentarios)
4,5
4,5
Avatar del usuario
See private message.
$12,75 USD en 3 días
4,6 (70 comentarios)
5,0
5,0
Avatar del usuario
See private message.
$6,80 USD en 3 días
4,9 (125 comentarios)
5,0
5,0
Avatar del usuario
See private message.
$21,25 USD en 3 días
4,7 (33 comentarios)
5,0
5,0
Avatar del usuario
See private message.
$17 USD en 3 días
4,8 (34 comentarios)
4,4
4,4
Avatar del usuario
See private message.
$13,60 USD en 3 días
5,0 (32 comentarios)
4,3
4,3
Avatar del usuario
See private message.
$12,75 USD en 3 días
4,7 (19 comentarios)
4,2
4,2
Avatar del usuario
See private message.
$17 USD en 3 días
5,0 (42 comentarios)
3,7
3,7
Avatar del usuario
See private message.
$12,75 USD en 3 días
5,0 (5 comentarios)
3,8
3,8
Avatar del usuario
See private message.
$20,40 USD en 3 días
4,6 (26 comentarios)
4,2
4,2
Avatar del usuario
See private message.
$21,25 USD en 3 días
5,0 (16 comentarios)
3,8
3,8
Avatar del usuario
See private message.
$20,40 USD en 3 días
4,8 (7 comentarios)
3,9
3,9
Avatar del usuario
See private message.
$21,25 USD en 3 días
3,8 (13 comentarios)
4,8
4,8
Avatar del usuario
See private message.
$12,75 USD en 3 días
4,6 (20 comentarios)
3,6
3,6

Sobre este cliente

Bandera de UNITED KINGDOM
Bristol, United Kingdom
4,1
70
Forma de pago verificada
Miembro desde abr 25, 2012

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.