Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fread syntax

Status
Not open for further replies.

martyhts

Programmer
Jun 21, 2000
1
US
I am not a C programmer but, using a SCADA package that uses C for its scripting. I need help with the following code snipet.<br>rfp = fopen(c:\textfile\group.lvl)<br>fread(name,1,8,rfp)<br>fread(password,1,26,rfp)<br>fclose rfp<br>In the fread funtion what are the ,1,8 and ,1,26 parameters?
 
Most likely the number of items to read and the size of each item<br>
 
From the fread man page:<br><FONT FACE=monospace><font color=red><br>size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);</font></font><br><br>Paraphrased:<br>fread copies data from a stream to an array. Your array is pointed to by name/password and then the size and nitems are meant to represent the amount of data copied and how many data items were in the section copied.<br><br>Finally Rfp is stream to the file your using. Looking at your code it would appear that in SCADA the function is written so that size and number of items are swapped (unless it is specifying 8/26 single characters read... which makes sense)<br><br>Hope that helped<br>Loon<br>
 
TomMcl2 is right. <p>Siddhartha Singh<br><a href=mailto:siddhu_singh@hotmail.com>siddhu_singh@hotmail.com</a><br><a href=siddhu.freehosting.net> </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top