simple task

task:
Create a program language C + +, which processes a text file in sequential mode.
Data from the file, reads one symbol (do not read all at once
a file or a whole-line).

There are two files f1 and f2. File f1 is arbitrary text, file f2 is
no more than 40 words for couple, separated by commas. Print file
text from the input file f1, which all the words that are occurring as a file f2
the first component of the couple, they are replaced with the corresponding file f2
word. You may believe(consider) that the file name length does not exceed 40
symbols. The word believe a series of arbitrary symbols, separated by
voids, or stop signs (point, comma, parentheses, exclamation points
mark, question mark).

Any help would be greateI (would be grateful for full code :))
PS. i translated tast text with google translater so yes it's sound funny but i think you can easily understand conditions
Last edited on
It sounds like a homework, you should do your homework by yourself, but if you are stuck somewhere, give us the code and and we will help in solving the problem.
you are mean but right i have to do it by my self :)
When i will have some code and will need help i will post :)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <fstream>
#include <iostream>
using namespace std;

int main ()
{
	char c, vards[40], replaase[40][2][40]; 
	int count, burts, x=0, y=0, z=0, i,h; 
	
	FILE * pf1, * pf2, * pf3;
	pf1 = fopen ("f1", "r");
	pf2 = fopen ("f2", "r");
	pf3 = fopen ("f3", "w");

	count = 0;

	do
	{
		c = fgetc (pf2); // ielasa
		if (c == EOF)
		{
			for (; z<40; z++) 
			{
				replaase[x][y][z] = ' ';
			}
			break;
		} else if (c == ',')
		{
			for (; z<40; z++)
			{
				replaase[x][y][z] = ' ';
			}
			z = 0;
			y = 1; 
		} else if (c == '\n')
		{
			for (; z<40; z++) 
			{
				replaase[x][y][z] = ' ';
			}
			z = 0; 
			y = 0; 
			x++; 
		} else
		{
			replaase[x][y][z] = c;
			z++; 
		}
	} while (c != EOF);
	
	count = x;
	for (x=0; x<=count; x++)
	{
		for (z=0; z<40; z++)
		{
			cout << replaase[x][0][z];
		}
		for (z=0; z<40; z++)
		{
			cout << replaase[x][1][z];
		}
		cout << endl;
	}

	burts = 0;
	do
	{
		c = fgetc (pf1); // ielasa
		if (c== EOF || c==' ' || c=='.' || c==',' || c=='(' || c==')' || c=='!' || c=='?')
		{
			atrada = false;
			for (; burts<40; burts++)
			{
				vards[burts] = ' ';
			}
			for (h=0; h<=count; h++) 
			{
				for (i=0; i<40; i++) 
				{
					if (vards[i] != replaase[h][0][i])
					{
						break;
					}
				}
				if (i==40)
				{
					atrada = true;
					break;
				}
			}
			if (atrada)
			{
				for (i=0; i<40,replaase[h][1][i]!=' '; i++)
				{
					fputc (replaase[h][1][i], pf3);
				}
			} else { 
				for (i=0; i<40,vards[i]!=' '; i++) 
				{
					fputc (vards[i], pf3);
				}
			}
			for (i=0; i<40; i++) 
			{
				vards[i] = ' ';
			}
			burts = 0;
			fputc (' ', pf3);
		} else {
			vards[burts] = c;
			burts++;
		}
	} while (c != EOF);

	fclose (pf1);
	fclose (pf2);
	fclose (pf3);
	system ("Pause");
	return 0;
}


so here is code maybe some things i should change but it seems to work fine
Topic archived. No new replies allowed.