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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

random access 1

Status
Not open for further replies.

freack

Programmer
Apr 13, 2000
2
US
me and some of my class mates are haveing trouble could some one help us out with it!!!
 
Please elaborate your point<br>Siddhartha singh<br><A HREF="mailto:ssingh@aztecsoft.com">ssingh@aztecsoft.com</A><br><br>
 
to the hard drive from a txt file instead of use the whole file just a peice of it. we would like to know what libraies to use on a program and how to establish it.
 
Please state your questions as clearly as possible. Do you mean you need to create a random access file and then retrieve the data from that same file?<br><br>For example, suppose you have a file that has last name, first name, sex, age, and&nbsp;&nbsp;description. Are you looking for a way to retrieve only the sex from each record in order to get the percentage of males to females?<br> <p>James P. Cottingham<br><a href=mailto:main@ivcusa.com>main@ivcusa.com</a><br><a href= Veneer Co., Inc.</a><br>All opinions are mine alone and do not necessarily reflect those of my employer.
 
Well..... In DOS based programs you can use (include IO.H):<br><br>long lseek(int handle, long offset, int fromwhere); <br>lseek sets the file pointer associated with handle to a new position offset bytes beyond the file location given by fromwhere.<br><br>In 16bit Windows applications (Win32 is simular and if you search your HLP file you'll see 32bit substitutions), you have more choices:<br>You can use:<br><br>_llseek which is very simular to the DOS one;<br>(Use SetFilePointer in Win32)<br><br>LONG _llseek(hf, lOffset, nOrigin)<br>HFILE hf; /* file handle */<br>LONG lOffset; /* number of bytes to move */<br>int nOrigin; /* position to move from */<br><br>Or you can use GetPrivateProfileString to automatically find stuff in an *.ini file for your program. Below is an excerpt from a win16 help file:<br><br>int GetPrivateProfileString(lpszSection, lpszEntry, lpszDefault, lpszReturnBuffer, cbReturnBuffer, lpszFilename)<br><br>LPCSTR lpszSection; /* address of section */<br>LPCSTR lpszEntry; /* address of entry */<br>LPCSTR lpszDefault; /* address of default string */<br>LPSTR lpszReturnBuffer; /* address of destination buffer */<br>int cbReturnBuffer; /* size of destination buffer */<br>LPCSTR lpszFilename; /* address of initialization filename */<br><br><br>The GetPrivateProfileString function retrieves a character string from the specified section in the specified initialization file. <br><br>Parameter Description<br><br>lpszSection Points to a null-terminated string that specifies the section containing the entry. <br>lpszEntry Points to the null-terminated string containing the entry whose associated string is to be retrieved. If this value is NULL, all entries in the section specified by the lpszSection parameter are copied to the buffer specified by the lpszReturnBuffer parameter. For more information, see the following Comments section. <br>lpszDefault Points to a null-terminated string that specifies the default value for the given entry if the entry cannot be found in the initialization file. This parameter must never be NULL. <br>lpszReturnBuffer Points to the buffer that receives the character string. <br>cbReturnBuffer Specifies the size, in bytes, of the buffer pointed to by the lpszReturnBuffer parameter. <br>lpszFilename Points to a null-terminated string that names the initialization file. If this parameter does not contain a full path, Windows searches for the file in the Windows directory. <br><br><br> <p> <br><a href=mailto:Kim_Christensen@telus.net>Kim_Christensen@telus.net</a><br><a href= Page</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top