Path: utzoo!attcan!uunet!husc6!rutgers!att!whuts!picuxa!gpasq From: gpasq@picuxa.UUCP (Greg Pasquariello X1190) Newsgroups: comp.lang.c Subject: Re: C Programming Problem Message-ID: <734@picuxa.UUCP> Date: 4 Jan 89 13:57:56 GMT References: <32229@auc.UUCP> Reply-To: gpasq@picuxa.UUCP (Greg Pasquariello X1190) Distribution: na Organization: AT&T/EDS Product Integration Center Lines: 38 In article <32229@auc.UUCP> tab@auc.UUCP (0-Terrence Brannon ) writes: -Ok, this is my source: ---------------------- - -#include - -main() -{ - FILE *fp; - char *a; - int i, q, r, s, t, u, v; - - - fp = fopen("tab.dat", "r"); - a = (char *) calloc (80, sizeof(char)); - - for (i=0, i < 3; ++i); - { - fscanf(fp, "%s %d %d %d %d %d %d", a, q, r, s, t, u, v); - printf("%s %d %d %d %d %d %d", a, q, r, s, t, u, v); - } -} - -Any ideas why valid integers from a file can't be read in as integers but -only can be read in a char strings? - -...!gatech!auc!tab They can, but you are doing it incorrectly. Look at the man page for fscanf, and you'll see that the parameters that fscanf takes are stream, format, and _POINTER_! You are not passing pointers to ints, you are only passing ints. Greg -- ============================================================================= Dirt is the mother o' lunch Greg Pasquariello AT&T/EDS att!picuxa!gpasq =============================================================================