- :
- . stdin;
- . stdout;
- . stderr.
, , , - . , , fgets () :
fgets(s, maxline, stdin);
fputs() :
fputs(s, stdout);
, /, , getc (fp), putc (c, fp), fp fp. fp, FILE, , . ߹, getchar (), putchar () ' stdio.h :
#define getchar() getc(stdin)
#define putchar() putc(stdout)
, stdio.h , , - .
( , freopen ()): ' p1.exe getchar (), :
p1.exe < anyFILE1
, anyFILE1. system () :
system("P1.EXE < ANYFILE1");
, DOS. , , . p2.exe, , :
p2.exe > anyFILE2
anyFILE2.
/
/. : - , / , - , / .
, , 3.
3
//--------------------------------------------------------------------
# pragma hdrstop
# include <stdio.h>
# include <conio.h>
# define eof 10
/* : 10 <Alt> +10 . 27 ( <Esc>) : , system () / , , . 10 ( <Enter>) , , getchar () */
|
|
# define no 0
# define yes 1
// ------------------------------------------------ --------------------
int main () {
int i = 0;
char m [1000];
/* , , */
int c;
int nc, nl, nw, in;
nc = nl = nw = 0;
in = no;
while ((c = getchar ())! = eof)
/* EOF stdio.h # define EOF -1 */ {
m [i] = c;
i++;
m [i] = '\0';
nc++;
if (c == '\ n')
nl + +;
if (c == '' || c == '\n' || c == '\t')
in = no; //
else if (in == no) // ߹ {
in = yes;
nw + +;
}
} // While
printf ("Entered from FILE =% s \ n", m);
printf ("Strings.... =%d \n", nl);
printf ("Words...... =%d \n", nw);
printf ("Charecters. =%d \n", nc);
getch ();
}
, ߹ /, 4.
4
/ / ------------------------------------------------ --------------------
# include <stdio.h>
# include <stdlib.h> // system ()
# include <conio.h> // getch ()
# pragma hdrstop
/ / ------------------------------------------------ --------------------
# pragma argsused
int main (int argc, char * argv []) {
/* PROJECT3_INPOUTREDIRECT.EXE PEREVIRKA.TXT */
system ("PROJECT3_INPOUTREDIRECT.EXE < PEREVIRKA.TXT");
/* PROJECT3_INPOUTREDIRECT.EXE PEREVIRKA1.TXT. , system () */
system ("PROJECT3_INPOUTREDIRECT.EXE> PEREVIRKA1.TXT");
getch ();
}
. 1.
. 1. /