Click here to Skip to main content
15,920,438 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to start app from inside code?? Pin
Antony M Kancidrowski17-Jun-04 1:37
Antony M Kancidrowski17-Jun-04 1:37 
Generalget the current working directory Pin
shiva shankar17-Jun-04 0:50
shiva shankar17-Jun-04 0:50 
GeneralRe: get the current working directory Pin
Dudi Avramov17-Jun-04 0:56
Dudi Avramov17-Jun-04 0:56 
GeneralManipulate text file Pin
?!?17-Jun-04 0:47
?!?17-Jun-04 0:47 
GeneralRe: Manipulate text file Pin
toxcct17-Jun-04 1:00
toxcct17-Jun-04 1:00 
GeneralRe: Manipulate text file Pin
V.17-Jun-04 2:02
professionalV.17-Jun-04 2:02 
GeneralRe: Manipulate text file Pin
chauteen25-Aug-04 22:44
chauteen25-Aug-04 22:44 
GeneralRe: Manipulate text file Pin
V.25-Aug-04 23:23
professionalV.25-Aug-04 23:23 
doesn't fscanf read the "\t", "\n" characters? if so. read the entire file in CString and handle the CString.

(you can always google, Codeguru, codeproject on tutorials and examples.)

info on fseek from MSDN:
Run-Time Library Reference

fseekSee Also
Stream I/O Routines | ftell | _lseek | rewind | Run-Time Routines and .NET Framework Equivalents
Requirements
Function Required header Compatibility
fseek <stdio.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.

Libraries

All versions of the C run-time libraries.
Moves the file pointer to a specified location.

int fseek(
FILE *stream,
long offset,
int origin
);
Parameters
stream
Pointer to FILE structure.
offset
Number of bytes from origin.
origin
Initial position.
Return Value
If successful, fseek returns 0. Otherwise, it returns a nonzero value. On devices incapable of seeking, the return value is undefined.

Remarks
The fseek function moves the file pointer (if any) associated with stream to a new location that is offset bytes from origin. The next operation on the stream takes place at the new location. On a stream open for update, the next operation can be either a read or a write. The argument origin must be one of the following constants, defined in STDIO.H:

SEEK_CUR
Current position of file pointer.
SEEK_END
End of file.
SEEK_SET
Beginning of file.
You can use fseek to reposition the pointer anywhere in a file. The pointer can also be positioned beyond the end of the file. fseek clears the end-of-file indicator and negates the effect of any prior ungetc calls against stream.

When a file is opened for appending data, the current file position is determined by the last I/O operation, not by where the next write would occur. If no I/O operation has yet occurred on a file opened for appending, the file position is the start of the file.

For streams opened in text mode, fseek has limited use, because carriage return–linefeed translations can cause fseek to produce unexpected results. The only fseek operations guaranteed to work on streams opened in text mode are:

Seeking with an offset of 0 relative to any of the origin values.
Seeking from the beginning of the file with an offset value returned from a call to ftell.
Also in text mode, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading/writing, fopen and all related routines check for a CTRL+Z at the end of the file and remove it if possible. This is done because using fseek and ftell to move within a file that ends with a CTRL+Z may cause fseek to behave improperly near the end of the file.

Requirements
Function Required header Compatibility
fseek <stdio.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.

Libraries

All versions of the C run-time libraries.

Example
// crt_fseek.c
/* This program opens the file FSEEK.OUT and
* moves the pointer to the file's beginning.
*/

#include <stdio.h>

int main( void )
{
FILE *stream;
char line[81];
int result;

stream = fopen( "fseek.out", "w+" );
if( stream == NULL )
printf( "The file fseek.out was not opened\n" );
else
{
fprintf( stream, "The fseek begins here: "
"This is the file 'fseek.out'.\n" );
result = fseek( stream, 23L, SEEK_SET);
if( result )
perror( "Fseek failed" );
else
{
printf( "File pointer is set to middle of first line.\n" );
fgets( line, 80, stream );
printf( "%s", line );

}
fclose( stream );
}
}
Output
File pointer is set to middle of first line.
This is the file 'fseek.out'.
See Also
Stream I/O Routines | ftell | _lseek | rewind | Run-Time Routines and .NET Framework Equivalents



--------------------------------------------------------------------------------

Send feedback on this topic to Microsoft

© Microsoft Corporation. All rights reserved.


"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
Generalstill wnat to ask_Re: Manipulate text file Pin
chauteen26-Aug-04 18:15
chauteen26-Aug-04 18:15 
GeneralRe: still wnat to ask_Re: Manipulate text file Pin
V.26-Aug-04 20:47
professionalV.26-Aug-04 20:47 
GeneralRe: still wnat to ask_Re: Manipulate text file Pin
Anonymous2-Sep-04 0:47
Anonymous2-Sep-04 0:47 
GeneralRe: still wnat to ask_Re: Manipulate text file Pin
V.2-Sep-04 1:21
professionalV.2-Sep-04 1:21 
GeneralRe: still wnat to ask_Re: Manipulate text file Pin
chauteen2-Sep-04 16:22
chauteen2-Sep-04 16:22 
GeneralRe: still wnat to ask_Re: Manipulate text file Pin
V.2-Sep-04 20:59
professionalV.2-Sep-04 20:59 
QuestionAre there good WMI samples, articles, books ? Pin
vgrigor117-Jun-04 0:37
vgrigor117-Jun-04 0:37 
AnswerRe: Are there good WMI samples, articles, books ? Pin
Antony M Kancidrowski17-Jun-04 1:52
Antony M Kancidrowski17-Jun-04 1:52 
Generalbatch file for setting env variables Pin
John Oliver17-Jun-04 0:05
John Oliver17-Jun-04 0:05 
GeneralRe: batch file for setting env variables Pin
David Crow17-Jun-04 3:15
David Crow17-Jun-04 3:15 
GeneralRe: batch file for setting env variables Pin
John Oliver17-Jun-04 3:39
John Oliver17-Jun-04 3:39 
QuestionAny idea on this simple application? Pin
Nelson L.16-Jun-04 22:25
Nelson L.16-Jun-04 22:25 
AnswerRe: Any idea on this simple application? Pin
John Oliver17-Jun-04 0:08
John Oliver17-Jun-04 0:08 
GeneralON_COMMAND_RANGE problem Pin
ThatsAlok16-Jun-04 22:20
ThatsAlok16-Jun-04 22:20 
GeneralRe: ON_COMMAND_RANGE problem Pin
Cedric Moonen16-Jun-04 23:24
Cedric Moonen16-Jun-04 23:24 
Generaloperator- in Date Class Pin
foxele16-Jun-04 21:35
foxele16-Jun-04 21:35 
GeneralRe: operator- in Date Class Pin
V.16-Jun-04 22:00
professionalV.16-Jun-04 22:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.