When I compile, I get these errors:
Code:
44 C:\Documents and Settings\xxxxx\My Documents\School\cis111\projects\d4test.c [Warning] passing arg 1 of `print_ssnum' makes integer from pointer without a cast
Code:
44 C:\Documents and Settings\xxxxx\My Documents\School\cis111\projects\d4test.c invalid use of void expression
I guess I dont see whats wrong with this code:
Code:
#include <stdio.h>
#include <stdlib.h>
int change(char *before) {
int after = 0;
char *end;
after = strtol(before, &end, 0);
after = (after * 100) + strtol(end + 1, &end, 0);
after = (after * 10000) + strtol(end + 1, &end, 0);
return after;
}
void print_ssnum(int pc) {
printf("%2d-%4d-%2d\n", pc / 1000000, pc / 10000, pc % 10000);
}
void main (void) {
struct student {
int grad_year; /* members defined here */
char ........n, *dob, name[40], curr[4];
};
struct student s;
struct student *sp;
s.grad_year = 2010;
s.ssn = "142-76-6900";
s.dob = "11/17/1975";
s.name;
s.curr;
sp = malloc (512 * sizeof(struct student)); /* Allocate memory 50 times 4 bytes wide */
strcpy(s.name, "Douglas W Van Allen");
strcpy(s.curr, "CIS");
*s.ssn = change(s.ssn);
*s.dob = change(s.dob);
printf("Cotents of s:\nName of Student = %s\nSocial Security Num = %d\nDate of Birth = %d\nCurriculum = %s\nGraduation year = %d\n",
s.name, print_ssnum(s.ssn), s.dob, s.curr, s.grad_year);
if (sp == NULL) { /* If memory can't be allocated */
printf("Cannot malloc\n");
exit(1);
}
free (sp);
}