Plz do ur best to help me I am a bit frustrated, can we solve this ??
I have like this in a file1.txt
OK Green > start 1
OK Green > start 2
No Green > start 3
OK orange > start 1
No orange > start 2
No orange > start 3
OK red > start 1
OK red > start 2
OK red > start 3
File2.txt has this
OK Green > start 1
No Green > start 2
Ok Green > start 3
No orange > start 1
Ok orange > start 2
No orange > start 3
OK red > start 1
OK red > start 2
No red > start 3
OK Green > start 1// note: the content of file1 again start from here
Ok Green > start 2
No Green > start 3
OK orange > start 1
No orange > start 2
No orange > start 3
OK red > start 1
OK red > start 2
OK red > start 3
how to make a function check() using std:map to do this :
for ex-
if (2 statements in file2.txt[18 commands] (Green Green) and (OK OK) return true
if both(Green Green)in file2.txt and (OK NO) return True
if both(Green Green) in file2.txt and (No Ok) return False
if both(Green Green) in file2.txt and (No No) return False
How can we do a compatible check for file1 as well as long it works properly with file2 ?? can be ;)
I think the associative map should have the (color + start_id) as the key, and the number of "OK" instances as the value.
Stop using streams. You're programming in a windows environment I would suggest using the native Windows API:
CreateFile
ReadFile
CloseHandle
Read your entire file into one memory buffer. As far as parsing your text file, use strtok() to tokenize the file into lines, and then process each line further tokenizing by spaces or however you want to do it. If you need to store all of this information into an array or matrix (an array of arrays), then you will need to probably find out how many lines there are in the text file, and dynamically allocate memory big enough to hold it.
Mainly because I don't personally like them and I prefer to use Windows API with multi-byte charset. I find unicode to be an annoyance.
If you want to ignore what I said about streams... you can't stream something like that into a multidimensional array and expect the computer to automatically tokenize and parse it for you. You need to code a parser by using string tokenization.
1. Unicode is the simplest of them all. Why is it annoying? Annoying is to have to convert from ANSI/Multi-byte to Unicode every time you want to pass a string to, say, a COM object. Now that's annoying!
2. Don't use strtok() unless you absolutely have to. Instead, if available, use strtok_s(). I say if available because I don't remember if it is Microsoft-specific.
3. I also am a fan of the Windows API, but in here you'll find people that like to write portable code, so dismissing streams like that is probably not going down well for some, hehe.
you can't stream something like that into a multidimensional array and expect the computer to automatically tokenize and parse it for you.
Yes, you can. Because that's exactly what it does.
I don't use standard C++ streams either, but to unnecessarily recommend using unportable WinAPI functions for something basic like reading a file and to recommend C functions like strtok as an "alternative" to C++ streams is ridiculous.
find out how many lines there are in the text file, and dynamically allocate memory big enough to hold it.
Or, you know, you could use a vector like a normal person.