Warning: Undefined global variable $skin in /home/u98739/softtime.ru/www/utils/utils.posts.php on line 82
Ответить на сообщение

Форум С++

 

Ответить на сообщение

Вернуться к теме

Вы отвечаете на сообщение:

Автор: Afinogen   (29.12.2007 в 02:06)
Смог сам сделать вот код одобренный преподавателем:

#include <vcl.h>
#include <windows.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream.h>
#pragma hdrstop
using namespace std;
string pr[100];
string p[]={"real", "byte", "readln", "exp", "keypressed", "writeln", "clrscr", "until", "repeat", "program", "uses", "var", "begin", "then", "if", "else", "function", "end.", "end"};
#pragma argsused
int main()
{
SetConsoleTitle("Работа с файлами");
FILE *F;
FILE *Fout;

char buf[500], s;
int n=300, j=0;

char * patch = new char[300];
char * token = new char[500];
cout << "File name: ";
cin >> patch;
patch="test.txt";
if ((F=fopen(patch, "r+t"))==NULL)
{
 cerr << "File not open!";
 return 0;
}
if ((Fout=fopen("out.txt", "w+t"))==NULL)
{
 cerr << "File not open!";
 return 0;
}

token=NULL;
while(fgets(buf, n, F)!=NULL) {
bool first=true;

while((token=strtok(first? buf : NULL, " 1234567890'><+*,-/:=();\n"))!=NULL)
{
bool t=true;
first=false;
for (int i=0;i<=18; i++)
if (strcmp(token, p[i].c_str())==0)
 {        t=false; break; }
for (int i=0;i<j;i++)
if (strcmp(token, pr[i].c_str())==0)
 {        t=false; break; }


if (t==true)    {
pr[j]=token;
fputs(token, Fout);
fputs("\n", Fout);
j++;            }
}

                             }
   fclose(F);
   fclose(Fout);
if (j>0) cout << "Zapicano indefikatorov: " <<  j;
else if (j==0) cout << "net indefikatorov";
   fflush(stdin);
   cin.get();
        return 0;
}


Ваше имя:

Пароль:

Цитировать

Используйте тэги для выделения текста:
Код: [code][/code]
Жирный: [b][/b]
Наклонный: [i][/i]
URL: [url][/url]

Сообщение:

Прикрепить: