473,386 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Reading data in from a file

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
3 5645
dru
29
anyone got any ideas?
Nov 5 '06 #2
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
dru
29
do you know another way?
Nov 5 '06 #4

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

Similar topics

0
by: travis ray | last post by:
Hi, I have an extension in which a file object is created in python and passed down to a c extension which attempts to read from it or write to it. Writing to the file pointer seems to work...
1
by: fabrice | last post by:
Hello, I've got trouble reading a text file (event viewer dump) by using the getline() function... After 200 - 300 lines that are read correctly, it suddenly stops reading the rest of the...
3
by: SB | last post by:
Hello. I have an input file which is laid out in the following manner... Name Day 1 am time 1 am time 2 appointment pm time 1 pm time 2 appointment Day 2
20
by: ishmael4 | last post by:
hello everyone! i have a problem with reading from binary file. i was googling and searching, but i just cant understand, why isnt this code working. i could use any help. here's the source code:...
1
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but...
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
5
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
13
by: swetha | last post by:
HI Every1, I have a problem in reading a binary file. Actually i want a C program which reads in the data from a file which is in binary format and i want to update values in it. The file...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.