02-09-2005, 20:26
|
|
|
|
חבר מתאריך: 04.08.02
הודעות: 4,468
|
|
...
Sorry I posted the wrong code
Forgot to paste the correct one, dont use the example above, I'm walking the memory without checking first If I'm allowed to.
קוד:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main( int argc, char **argv )
{
FILE *fpOutput;
char sInput[1024];
char *p;
fpOutput = fopen( "test.txt", "w" );
if( fpOutput == NULL )
{
perror( "fopen:" );
return EXIT_FAILURE;
}
printf( "Enter your input:" );
fgets( sInput, sizeof( sInput ), stdin );
p = sInput;
while( *p != '\n' )
{
if( *p == 'a' )
fputs( "55\r\n", fpOutput );
if( p != sInput )
if( *(p-1) == 'a' && *p == 'e' )
fputs( "21\r\n", fpOutput );
p++;
}
fclose( fpOutput );
return 0;
}
_____________________________________
C pogrammers never die. They are just cast into void.
|