By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,233 Members | 1,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,233 IT Pros & Developers. It's quick & easy.

Reading data in from a file

P: 29
I am trying to read data in to a struct from a prototype

My Code is:
Expand|Select|Wrap|Line Numbers
  1. void init(student_record db[],int *count)
  2. {
  3.     FILE *input;
  4.     char temp_str[30];
  5.     input = fopen("mydata.txt","r");
  6.  
  7.     while(!feof(input) && count<SIZE)
  8.     {
  9.         fscanf_s(input,"%s",temp_str);
  10.         strcpy_s(db[*count].firstname,temp_str);
  11.         fscanf_s(input,"%s",temp_str);
  12.         strcpy_s(db[*count].lastname,temp_str);
  13.         fscanf_s(input,"%s",temp_str);
  14.         strcpy_s(db[*count].ssno,temp_str);
  15.         fscanf_s(input,"%s",temp_str);
  16.         strcpy_s(db[*count].city,temp_str);
  17.         fscanf_s(input,"%s",temp_str);
  18.         strcpy_s(db[*count].state,temp_str);
  19.         fscanf_s(input,"%s",temp_str);
  20.         strcpy_s(db[*count].year,temp_str);
  21.         fscanf_s(input,"%s",temp_str);
  22.         strcpy_s(db[*count].sex,temp_str);
  23.         fclose(input);
  24.     }
  25. }
  26.  
  27.  
My complier is saying this:
error C2198: 'strcpy_s' : too few arguments for call
warning C4047: 'function' : 'rsize_t' differs in levels of indirection from 'char [30]'
warning C4024: 'strcpy_s' : different types for formal and actual parameter 2

Anyone have any ideas????
Nov 4 '06 #1
Share this Question
Share on Google+
3 Replies


P: 29
dru
anyone got any ideas?
Nov 5 '06 #2

P: 3
I am trying to read data in to a struct from a prototype

My Code is:
Expand|Select|Wrap|Line Numbers
  1. void init(student_record db[],int *count)
  2. {
  3.     FILE *input;
  4.     char temp_str[30];
  5.     input = fopen("mydata.txt","r");
  6.  
  7.     while(!feof(input) && count<SIZE)
  8.     {
  9.         fscanf_s(input,"%s",temp_str);
  10.         strcpy_s(db[*count].firstname,temp_str);
  11.         fscanf_s(input,"%s",temp_str);
  12.         strcpy_s(db[*count].lastname,temp_str);
  13.         fscanf_s(input,"%s",temp_str);
  14.         strcpy_s(db[*count].ssno,temp_str);
  15.         fscanf_s(input,"%s",temp_str);
  16.         strcpy_s(db[*count].city,temp_str);
  17.         fscanf_s(input,"%s",temp_str);
  18.         strcpy_s(db[*count].state,temp_str);
  19.         fscanf_s(input,"%s",temp_str);
  20.         strcpy_s(db[*count].year,temp_str);
  21.         fscanf_s(input,"%s",temp_str);
  22.         strcpy_s(db[*count].sex,temp_str);
  23.         fclose(input);
  24.     }
  25. }
  26.  
  27.  
My complier is saying this:
error C2198: 'strcpy_s' : too few arguments for call
warning C4047: 'function' : 'rsize_t' differs in levels of indirection from 'char [30]'
warning C4024: 'strcpy_s' : different types for formal and actual parameter 2

Anyone have any ideas????
"strcpy" (string copy) thorws error on integer and float variables... ! check on it may be!
Nov 5 '06 #3

P: 29
dru
do you know another way?
Nov 5 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.