.


:




:

































 

 

 

 


. .




// :

1 (, ) .

p = fopen( \-, w);

2 ( dfa21.cpp) . :

) , , \bcw, OK bcw bc Windows

) , , , , Enter

( ):

) , , d:\borlandc\bin\bcw, OK Borland C++, File, Open, dfa21.cpp, 2click dfa21.cpp.

) , , , , () ,

d:\borlandc\bin\bcw d:\borlandc\bin\dfa21.cpp, Enter Borlandc C++ dfa21.cpp.

 

.

=0!

, .

/*File is absent fopen(), fclose() - ,

putc()/fputc(), getc()/fgetc() - ..,

fputs(), fgets() - ..,

fseek(), ftell() - ,

fprintf(),fscanf()- printf(),scanf()

feof(), ferror()- true ,

rewind(), remove()- ,

fflush - ()

 

r, w, a - , ,

rb, wb, ab - "-"

r+, w+, a+ - , , , + -

r+b,w+b,a+b-

 

=0 //15

*/

#include <iostream.h>

#include <stdlib.h>

#include <stdio.h>

#include <ctype.h>

#include <string.h>

#include <conio.h> //22

 

int main(/*int argc, char *argv[2]*/)

{ FILE *fp;

char c;

int k, i=0; // =1

int argc; char *argv[1]; //28

m:printf(" k=(0/0) (/c) Enter\n");

scanf(" %1d", &k);

// getch()

switch(k) //33

{ case 0: if((fp=fopen("d:\dfa201.doc","w"))==NULL)

{ printf(" _1\n");

exit(1);

}

break;

/* case 1: if(argc!=2)

{ printf(" , argc=%d \n", argc);

exit(1);

}

if((fp=fopen(argv[1], "w"))==NULL)

{ printf(" , argv[1]=%d \n", argv[1]);

exit(1);

}

break;

*/ default: printf(" 0 /* 1*/\n"); ++i; if(i>=3)exit(1);goto m;

} //49

printf(" d:\dfa201 ! \n");

do { c=getche(); //

putc(c,fp); //

if (c=='$')break;

printf("\n to finish press symbol $\n");

} while (c!= '$'); //55

printf(" !\n\n");

fclose(fp);

getch();

return 0;

} //60

 

, , . !

!

 

. . .

 

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <conio.h>

 

int main(void)

{ FILE *fp;

char str[80];

// a+ - dfa201

if ((fp=fopen("d:\dfa201.doc","a+"))==NULL)

{ printf(" .\n");

exit(1);

}

/* rewind(fp);

while(!feof(fp))

{ fgets(str,79, fp);

printf(" str=%s\n",str);

}

*/

//

do { printf(" . Enter\n");

gets(str); //printf(" str=%s\n",str);

strcat(str, "\n"); // \n

fputs(str, fp); // dfa201

} while(*str!='\n');

//

rewind(fp); //

while(!feof(fp))

{ fgets(str, 79, fp); //

printf(str); //

}

 

return 0;

}

 

 





:


: 2016-09-06; !; : 616 |


:

:

80% - .
==> ...

1587 - | 1449 -


© 2015-2024 lektsii.org - -

: 0.01 .