vector help

closed account (3vCpfSEw)
I think I need a vector example

I need to be able to read the text file

"text1" "response1"
"text2" "response2"


and put them in as variables for this function

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
if (!strcmp(text.c_str(), text1))
				{
					bot_exchange_format p(PLUGIN_EVENT_ROOM_TEXT);
					p << bot_value(0x01, response1);
					p << bot_value(0x02, attributes);
					p << bot_value(0x03, size);
					p << bot_value(0x04, color);
					p << bot_value(0x05, effects);
					p << bot_value(0x06, charset);
					p << bot_value(0x07, pitch);
					p << bot_value(0x08, font);
else if (!strcmp(text.c_str(), text2))
				{
					bot_exchange_format p(PLUGIN_EVENT_ROOM_TEXT);
					p << bot_value(0x01, response2);
					p << bot_value(0x02, attributes);
					p << bot_value(0x03, size);
					p << bot_value(0x04, color);
					p << bot_value(0x05, effects);
					p << bot_value(0x06, charset);
					p << bot_value(0x07, pitch);
					p << bot_value(0x08, font);



I have tried doing

1
2
3
4
5
6
7
8
                std::string trigger[255];  // etc
		std::string alert[255];
		int i=0;
		for(i=0; i<255; i++)
			fscanf(f,"\"%s\" \"%s\"",&trigger[i],&alert[i]);
			i++;
		
		fclose(f);


I am in need of a vector struct for this I believe
Last edited on
Any particular reason for mixing C and C++?
Try with fgets function. The characters vector must be declared like that: char name[length] where name is the name of that vector and length is the length of that vector. It's easy.
Hi ,
I am not clear what all of you are talking about . please elobrate ..so that i can understand .
Soory for my lack of knowledge on the subject .
Thanks in advance
XXX
Topic archived. No new replies allowed.