The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 EOF
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ovince

Yugoslavia
Posts

Posted - 10/28/2006 :  03:49:08 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
hi


I would also like to simulate while loop with idea to read out data from fajl while not EndOfFile is encoutered. How to do it?


thanks
oliver

zachary_origin

China
Posts

Posted - 10/28/2006 :  05:59:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Oliver,


1. Use the funtions for file I/O.


void test_feof()
{
int count, total = 0;
char buffer[100];
FILE *stream;

// open your current using C file for read
stream = fopen( __FILE__, "r" );
if(stream == NULL )
printf( "The current C file was not opened\n" );

// Cycle until end of file reached:
while( !feof( stream ) )
{
// Attempt to read in 10 bytes:
count = fread( buffer, sizeof( char ), 100, stream );
if( ferror( stream ) )
printf("Read Error");

// Total up actual bytes read
total += count;
}

printf( "Number of bytes read = %d\n", total );
fclose( stream );
}



For more details, see Help: Programming: Origin C Language Reference: Global Functions: File I/O.

2. Use Worksheet::ImportASCII to import the data file into a worksheet. see Help: Programming: Origin C Language Reference: Classes: Internal Origin Objects: Worksheet::ImportASCII


Zachary
OriginLab Technical Services.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000