Split strings + writing into variable under condition

Hello

This program read file and then it uses strcspn() to split strings. It displays words. I'd like to modify program now to check if variable "moja" equals some of words in "pairs.txt". If that's true, user should can write into "moja" every word from "pairs.txt" except words being in line where is actual word in "moja".
Now "moja" = "baza2" so user should can write into "moja" only words from second line of "pairs.txt". Could you give me any tips?
PS. sorry for my english.

pairs.txt
1
2
baza1;baza2;baza3
zamek1;zamek2;zamek3


file.cpp
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
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std; 
int pairs()
{
   
static const char filename[] = "pairs.txt"; 
FILE *file = fopen(filename, "r");
if ( file )
{
char line[BUFSIZ]; 
int k = 0;
while ( fgets(line, sizeof line, file) ) 
{
int i;
char *token = line;
printf("linia %d:\n", ++k);
for ( i = 0; *token; ++i ) 
{

size_t len = strcspn(token, ";\n");

printf("lancuch[%2d] = \"%*.*s\"\n", i, (int)len, (int)len, token);

token += len + 1;
}
const char* moja = "baza2"; 
}
fclose(file);
}    
}

int main(void)
{
    pairs();
    system("PAUSE");
    return EXIT_SUCCESS;
}
Topic archived. No new replies allowed.