prog5 - exit (1); } fgets(LineIn, 250,fp1);...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* Matt Hergenrether CS2433 C/C++ Programming March 26, 2009 2:00pm */ #include <stdio.h> #include <string.h> #include <unistd.h> #include <stdlib.h> struct csclass{ char lastname[20]; char firstname[20]; double points; char grade; } ; char compute_grade(double point); /* function prototype */ void main (int argc, char * argv[]) { /*declaring variables*/ struct csclass temp, student[100]; char LineIn[250]; char s2[3]; double pointstemp = 0.0; int i = 0; int k =0; char gradetemp; char *hold; strcpy(s2, " "); FILE *fp1; if(argc < 2) { printf("A command line arguments is required\n"); exit(0); } fp1 = fopen(argv[1], "r"); if (fp1 == NULL) { printf("%s could not be opened\n", argv [1]);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: exit (1); } fgets(LineIn, 250,fp1); while(!feof(fp1)) { hold = strtok(LineIn, s2); strcpy(student[i].lastname , hold); hold = strtok(NULL, s2); strcpy(student[i].firstname , hold); hold = strtok(NULL, s2); student[i].points = strtod(hold, NULL); pointstemp=student[i].points; strcpy(student[i].points, compute_grade(pointstemp)); i++; fgets(LineIn, 250, fp1); } for(k; k<100; k++) { if (student[k].lastname != NULL) { printf("%s ", student[k].lastname); printf("%s ", student[k].firstname); printf("%d\n", student[k].points); } } fclose(fp1); } char compute_grade(double a) /*function definition */ { return A; }...
View Full Document

This note was uploaded on 09/28/2011 for the course CS 1113 taught by Professor Chandler during the Fall '08 term at Oklahoma State.

Page1 / 2

prog5 - exit (1); } fgets(LineIn, 250,fp1);...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online