Murtan 317 Practically a Master Poster

What part have you written and/or what specific question do you have?

- Did you get the binary file open?
- Did you fill the vector from the file?
- Did you find the start point of the string?
- Were you able to append characters to your string from the vector?
- Did you find the 'NULL' in the vector to know that you're done filling the string?
- Did you successfully call fopen?
- Did you successfully read the data with scanf?

We generally will not write your program for you, but will help when you show you're trying.

Murtan 317 Practically a Master Poster

Not to be rude about it, but why do you care if the user entered '-verbose' or '--verbose'?

If they both make the output verbose, why should they care?

Murtan 317 Practically a Master Poster

So your current data set is about 25 players with 20 statistics each?

Do you anticipate the number of players or the number of statistics to grow?

How critical is it that updates to the data be committed to disk immediately? (How bad would it be to 'lose' one or more updates?)

With your current data size, you could have an application that read the data, perform one or more updates to the data and then write the data as it exits normally. The primary drawback being the 'exits normally' phrase. If it did not exit normally, all of the updates from that run would be lost. It could be extended slightly to write the whole file every time any data changed as long as the target media (hard-drive?) was fast enough that it didn't hold you up from making the next update. Alternatively you could maintain a 'transaction file' with a list of the changes you make as you make them that is deleted after the whole file is written. It would contain data something like "Player 1's Stat 6 is now 12" though in practice the data in the file would likely be 1;6;12 . When your program starts up and reads the data file, it looks for the transaction file and performs any updates it finds. (If it finds any, I would write the file at that point and then delete the transaction file.)

It has the advantage that the file is probably …

Murtan 317 Practically a Master Poster

If you're running the commview tool on your same computer, I guess the packets are on your network (though I wouldn't have expected them to be).

Is there any way to associate a 239.x.x.x address with your computer (as well as your current ip address) so that you are 'entitled' to the messages?

If not, I vaguely recall a mode for a connection or card that allowed it to 'see' network packets that were not addressed to it. (If commview is seeing the 239 broadcasts I think that's how it works), but I'm not aware of how to put it in that mode.

I remembered the name 'promiscuous mode' for this type of connection. Looking it up as a definition I find:
http://en.wikipedia.org/wiki/Promiscuous_mode

Murtan 317 Practically a Master Poster

So you don't want to append to the file, you want to update its contents?

How many files are there? One per team? One per player? One per stat?

If the file is in ASCII form (like your sample stat was) and you need to update it, you will likely have to re-write the entire file every time you change anything. If the file is small enough and the data is all available, this isn't necessarily a bad implementation.

If the data is organized into fixed size records, you can perform partial file updates by calculating the position to seek() to and just writing the updated data. (Note that seek and open for append don't get along well together.)

Murtan 317 Practically a Master Poster

It was my understanding (and I did a little searching that didn't disagree) packets sent to 239.255.255.255 should be available to anyone with a 239.x.x.x address.

Does your computer have a 239.x.x.x address?

Are you listening to the right port?

Murtan 317 Practically a Master Poster

Think about it...how would YOU do it?

All you really have to do is additional testing in the year they would turn 18.
If they would turn 17 (or younger) this year they fail.
If they would turn 19 (or older) this year they pass (they're already 18).
If they turn 18 this year you have to compare the months.
If they turn 18 this month, you have to compare the date.

Write some more and ask again if you still can't figure it out, but post what you write along with a specific problem. Something like "It's doing X but I want it to do Y".

Murtan 317 Practically a Master Poster

I found this code example

use Getopt::Long;
my $data = "file.dat";
my $length = 24;
my $verbose;
$result = GetOptions ("length=i" => \$length, # numeric
                      "file=s" => \$data, # string
                      "verbose" => \$verbose); # flag

at http://perldoc.perl.org/Getopt/Long.html

(The first page returned for google "perl getopt long")

If you've read through that page and still have questions, post specific questions with a little more detail on what it does now vs what you want it to do.

Murtan 317 Practically a Master Poster

I don't get it...I modified your file only slightly (below) and the run looks like this:

$VAR1 = {
          'C2_GLH3' => 'GLUC + ATP = GLUC6P + ADP',
          'A1_HTTT24' => 'GLUC_ext = GLUC',
          'B3_PGAI1' => 'GLUC6P = FRUC6P'
        };
Enter reaction name for searching:C2_GLH
Can't find 'C2_GLH' in the file
Enter reaction name for searching:C2_GLH3
C2_GLH3,GLUC + ATP = GLUC6P + ADP
Enter reaction name for searching:APPLE
Can't find 'APPLE' in the file
Enter reaction name for searching:B3_PGAI1
B3_PGAI1,GLUC6P = FRUC6P
Enter reaction name for searching:

and the output file contains this:

C2_GLH3,GLUC + ATP = GLUC6P + ADP
B3_PGAI1,GLUC6P = FRUC6P

Source:

use strict; 
use warnings; 
use Data::Dumper; 

my %reacts;
my $database = "reaction_database.txt";
open(Dbase,"<$database") or die "can't open $database $!";

# Simplified read loop
# Sample input data
#A1_HTTT24 : GLUC_ext = GLUC .
while (my $line = <Dbase>) {
	# optional whitespace, KEY, optional whitespace, required ':', optional whitespace, VALUE, required whitespace, required '.'
	$line =~ m/^\s*(\S+)\s*:\s*(.*)\s+\./;
	$reacts{$1} = $2;
}

close(Dbase);

#debug to confirm file contents -- left in so I could 'see' something to type
print Dumper \%reacts;

my $input;
open (DATA,"+>react_out.txt") or die "Can't open data"; 

do { 
	print "Enter reaction name for searching:"; 
	$input=<>; 
	chomp($input); 
	if (not $input=~/^\s*$/) {
		if(exists $reacts{$input}) { 
			# feedback on what was matched
			print "$input,$reacts{$input}\n"; 
			print DATA "$input,$reacts{$input}\n"; 
		} 
		else { 
			# explicit feedback for what was not found
			print "Can't find '$input' in the file\n"; 
		} 
	}
}until($input=~/^\s*$/); 

close(DATA);
Murtan 317 Practically a Master Poster

Did you try letting the dumper run?
What did you see?

The $1 and $2 in my code are from the regular expression.
They evaluate to the first and second 'groups' in the regex.

$line =~ m/^\s*(\S+)\s*:\s*(.*)\s*\./;
# The above regular expression is decoded as:
#    Starting at the beginning of the line    ^
#    Match zero or more white space           \s*
#    Match one or more non-white space        (\S+)
#         saving it as group 1
#    Match zero or more white space           \s*
#    Match a colon                            :
#    Match zero or more white space           \s*
#    Match zero or more of any character      (.*)
#         saving it as group 2
#    Match zero or more white space           \s*
#    Match a period                           \.
$reacts{$1} = $2;
# This then uses the first saved group as the key and the
# second saved group as the value

You left the split in, but you're using the $1 and $2 from the regex.

Try this (modified from your last post):

use strict; 
use warnings; 
use Data::Dumper; 
 
my ($key,$val);
my $database = 'file.txt'; 
my (%hash,$input); 
open(Dbase,"<$database") or die "can't open $database $!"; 
while (my $line = <Dbase>){ 
chomp $line;  
$line =~ m/^\s*(\S+)\s*:\s*(.*)\s*\./;
	#$reacts{$1} = $2;
#my ($key,$val)=split('\s*:\s*',$line);
#$key =~ /([^\s]+)/;
$key = $1;
#$val =~ /(^\s+)(.+)(\s\.)/;
$val = $2;
$hash{$key}=$val; 
} 
close Dbase; 
#print Dumper \%hash; 
open (DATA,"+>data.txt") or die "Can't open data"; 
do { 
	print "Enter reaction name for searching:"; 
	$input=<>; 
	chomp($input); 
	if(exists $hash{$input}) …
Murtan 317 Practically a Master Poster

If you'd post the errors, or what the program is doing that it shouldn't (or isn't doing that it should). I'd have more of a clue as to what to do to help you.

If you're getting a compile error, the actual compiler message along with several lines on either side of the 'problem' would better allow me to help.

If its a run-time error, the actual error message as well as the associated source code would be necessary.

Keep us posted, good luck.

Murtan 317 Practically a Master Poster

I don't think you're adding what you think you are. I think the regex match inside the split is overwriting $1 and $2 before you save them.

I would tend to declare $key and $val outside the loop on line 5, and then comment out the split on line 11 to make sure $1 and $2 are preserved -- you don't use the results from the split anyway.

I think that will work.

For debug, you might print all of the key values you add to the hash or with a little more work, you could just print the first ten added or some other subset of the whole.

Murtan 317 Practically a Master Poster

You want to put the date and time in the title of the window that pops up, or do you want the name of the directory to contain the date and/or time?

For getting the date/time into a string, you might look at strftime() and you should probably also consider calling mkdir() instead of system("mkdir ...") to create the directory.

Salem commented: Nice +19
Murtan 317 Practically a Master Poster

I think what he was trying to point out is that while it is perfectly permissible to compare two integer values using the equality operator "==" that you can't rely on it for double or floating point values.

When comparing floating point values, you usually compare the absolute value of their difference to see if it is less than a threshold. Something like if (fabs(dblA - dblB) < 0.001) which is true if the two values are less than 1/1000 apart. The value 0.001 can be modified to increase or decrease the required precision.

Murtan 317 Practically a Master Poster

Here's my test code for the read and store portions...you still need to write the retrieval code. If you have any questions about the code, please ask.

my %reacts;
$database = "reaction_database.txt";
open(Dbase,"<$database") or die "can't open $database $!";

# Simplified read loop
# Sample input data
#A1_HTTT24 : GLUC_ext = GLUC .
while (my $line = <Dbase>) {
	# Regex [whitespace]KEY[whitespace]:[whitespace]VALUE[whitespace].
	# optional whitespace, key, optional whitespace, required ':', optional whitespace, value, optional whitespace, required '.'
	$line =~ m/^\s*(\S+)\s*:\s*(.*)\s*\./;
	$reacts{$1} = $2;
}

close(Dbase);

#debug to make sure I read my data file correctly
#    I only had the three lines -- you may want to skip this if you have a lot of lines
while ( my ($kk, $vv) = each(%reacts) ) {
	print "$kk => $vv\n";
}
Murtan 317 Practically a Master Poster

I don't see where you're storing them.

Did you possibly mean to declare a hash?

#declaration
my %reacts;
# store one
$reacts{$key} =$value;
# test to see if one exists
if exists $reacts{$testkey} { ... }

Declare before the read loop
add a store between original lines 11 and 12
use the test in place of original line 21's while loop

Try that and if it doesn't work, post the new code and we'll look at it.

Murtan 317 Practically a Master Poster

did you mean to save the key and value pairs you read in so you can search them when you open the second file?

Murtan 317 Practically a Master Poster

int variables only hold integer values (-12, 0, 5, 9)
float and double variables hold floating point values (-3.6, 0.1, 5.3, 9.0)

doubles have more precision as to the number of significant digits, but consume more memory.

I prefer to use int (or long) values when an integer value is appropriate as operations using integer values are much faster than their floating point equivalents. I only use doubles for floating point values unless I have a need to use less memory, disk space or bandwidth.

For string input look at gets() or fgets(). I prefer fgets because I can protect my string from being overrun.

Murtan 317 Practically a Master Poster

It was a link to another thread that explains why not to use eof() in your while loop condition. Click the link, read the thread and implement the change.

Murtan 317 Practically a Master Poster

I wouldn't have written it in the same way, but I think your problem is two-fold:

First, you never set an initial value for DivSales::totalSales so it's initial value is undefined.

Second, line 21 of DivSales.h where you think you are adding to the total,

totalSales =+ q0+q1+q2+q3;
// This is the same as
totalSales =      (+q0) + q1 + q2 + q3;
// I think you wanted
totalSales += q0 + q1 + q2 + q3;
// That is the same as
totalSales = totalSales + q0 + q1 + q2 + q3;

I wouldn't have the class 'own' a total for all the instances. I would have each instance of the DivSales class total its own sales (so it would know all 4 quarters and its own total). I would then add functionality to be able to accumulate DivSales within another DivSales. You would initialize the 'company' DivSales to zeros and then add each of the Divisions DivSales as it is filled in. You could at that point then display the company totals for each quarter and an overall value.

For tabular output I would expect to output something like the following:

Division        Q1      Q2      Q3      Q4      Total
    1          225     242     334     326       1127
    2          100     100     100     100        400
--------     -----   -----   -----   -----    -------
Total          325     342     434     426       1527
Murtan 317 Practically a Master Poster

line 24 is passing the address of a function to scanf?
I think you meant scanf("%f", &inch); line 35 you need to pass the address of restart scanf("%f", &restart);

Murtan 317 Practically a Master Poster

I don't see anywhere that you are not releasing memory you have allocated.

I however, would not have used quite so much allocation. For example the filename is declared and used as follows. The buffer is explicitly allocated, filled, passed to another function and explicitly deallocated.

char * filename = new char[30];
   cin >> filename;
   readin(pc, size, filename);
   delete [] filename;

Using a stack-based local variable is simpler and does not require actual allocation and deallocation. The buffer is declared, filled, passed to another function and released when the function exits.

char filename[255];
   cin >> filename;
   readin(pc, size, filename);

You may have noticed that I 'sized up' the filename buffer. When you're working with user input, you should have more room available than the user is ever likely to provide. (Some input functions don't check to make sure you have enough.)

I would still argue that the brand and model character buffers should be explicitly sized as well. Your sample program only has 2 instances of the computer structure, but each time you use a computer structure, you have to perform 3 allocations. One for the structure and two more for the character buffers. If the character buffers are always going to be allocated at 15 characters in size, just go ahead and declare them that size. The first allocation would have to go get more memory, but you would not have to make the two additional allocations.

I would have declared it as:


       
Murtan 317 Practically a Master Poster

I'm not sure what the question is.

You declare a pointer to an object of the appropriate type on line 17, in most linked lists I've seen, it is usually named "next" but other than that I don't see a problem.

You do appear to be declaring one on line 23 as well, or was that supposed to be an accessor?

If is were my implementation the private member would be ProcessedPayroll* pNext; and the accessor would be ProcessedPayroll * getNext() and the mutator void setNext(ProcessedPayroll * next) For the rest of the linked list, you need to have a "head" pointer that either points to NULL if the list is empty, or the first object in the list. The last object on the list will have its "next" pointer point to NULL.

How things are added to the linked list depends on the importance of ordering to the list. For a standard linked list, it is easiest to add elements at the head, but then when the data is accessed in the normal fashion, the data is in the opposite order from how it was added. (The last added would be the first seen.)

If the elements are to be added to the end of the linked list to maintain the order, you must either iterate to the end of the list every time you want to add one, or maintain a pointer to the "tail" (last object in the list -- NULL if …

Murtan 317 Practically a Master Poster

You put your variable definitions in a .py file you could name it definevble.py if you wanted to.

Then from the other python file (.py) that wanted the variables you add a line:

from definevble import *

That imports everything in that file into this file.

I think that will do what you want.

For example if vardefs.py contains:

pie="Apple"

and vartest.py contains:

from vardefs import *
print pie

The output of vartest.py will be "Apple"

Murtan 317 Practically a Master Poster

At first glance, it looks pretty close to me.

So I loaded it up in Visual Studio, cobbled together a data file named "data." using notepad and it seems to run for me.

The data file contains:

2
Dell Inspiron 299
Hp Pavilion 499

When I run the program I get:

enter the file name :
data
brand:Dell   model:Inspiron   price:$299
brand:Hp   model:Pavilion   price:$499
Press any key to continue . . .

That looks right to me.

What are you seeing?

NOTE: I did explicitly over-ride the default working directory to the directory where the data file was created. Either do that or make sure your data file is in the correct directory or the program won't be able to find it. Alternatively, you could enter the full path to the data file, but you only allowed 30 characters so don't overflow it.

Murtan 317 Practically a Master Poster

You appear to be having some trouble with scoping.

No function can see the local variables of another function unless that other function passes them as arguments.

The filename declared on line 19 is the one that main puts the name the user enters into. The filename declared on line 47 and used on line 48 will NOT contain the filename. So to start with, you aren't opening the right file in readin().

You could easily add another parameter for the filename readin(char * filename, computer * & pc, int size); Also, readin() if it reads the right file, reads in the size and main and printF expect to be able to use the size, but the size is local to readin(). If you want readin() to set the size and for main to see it, you have to pass the size by reference (like you did the computer array.) readin(char * filename, computer * & pc, int & size); To simplify the rest of the code, you could skip allocating character strings for the brand and the model by just declaring them with size in the structure:

struct computer{
   char brand[15];
   char model[15];
   double  price;
   };

(As a matter of personal preference, I like declared types to start with a capital letter and I like indenting so my declaration would look more like this:

struct Computer {
      char brand[15];
      char model[15];
      double  price;
   };

but it is your code.)

readin() just allocated the …

Murtan 317 Practically a Master Poster

any chance you can post what you have now (in code tags) so I can look at it?

Murtan 317 Practically a Master Poster

If your data file really looks like:

2
Dell inspiron 299
Hp pavilion 499

You will not be able to use a standard stream read for the name. The standard string read will stop at the first space. You will need to perform something like a line read (see getline()) and then parse the string you read to find the number at the end of the line.

Murtan 317 Practically a Master Poster

the ifstream fin on line 48 inside readin() is NOT the same as the stream of the same name that is declared on line 20 and opened on line 24 in main().

You either need to open the file in readin() or pass the stream from main into readin().

Murtan 317 Practically a Master Poster

I don't want to spend the time to figure out if your program does exactly what the spec calls for, I'd rather help you get your program to do what you expect.

What are you seeing it do that is unexpected?

(What are the symptoms)

You might want to add some temporary debug output (or run the program in a debugger) so you have a better idea of what is going on inside.

Murtan 317 Practically a Master Poster

In C# a function can return only one value. You're passing the fraction into the simply function as a numerator and a denominator and the function is unable to return both.

Alternatives would be to 'package' the numerator and denominator into a struct or class which you could pass in and return, or you could make the parameters reference parameters allowing the function to make changes 'in-place' in the variables passed to the function.

Murtan 317 Practically a Master Poster

There are several options, most of them make the protocol significantly more complex. The goal would be to verify the client and/or the response.

You could start each conversation with some kind of challenge and response. Where your code would know how to respond and a fake client would have to reverse engineer the correct response.

You could incorporate a form of challenge/response into the reply data. If the reply were to include say the timestamp of the request, the timestamp of the reply, the dataset analyzed, the reply and a 'checksum' or signature your server could use that data to verify that the reply matches an outstanding request and came from a 'proper' client.

For the type of problem you described, an alternative might be to send the request out multiple times (to different clients) and compare all of their responses. If you have one client repeatedly not matching the other clients, its probably a bad (fake) client.

I'm sure there are other ways as well, but those are the first that came to mind.

Murtan 317 Practically a Master Poster

Show me some code.

I want to see your database access and at least one attempt at making a copy of the data.

Murtan 317 Practically a Master Poster
Murtan 317 Practically a Master Poster

You don't want the 'foreach' on line 9, you don't want to add a record to the database for every field on the line.

and presuming that the construct cmd.Parameters.Add("@acc", SqlDbType.NVarChar).Value = part[i]; makes sense (I've not seen it before so I'll trust you that it will work). You will need to have each of the command parameters access the appropriate field from the line. In this case I think it should be cmd.Parameters.Add("@acc", SqlDbType.NVarChar).Value = parts[0];

Murtan 317 Practically a Master Poster

Ok it would seem your design is at least a reasonable choice then.

Will you have any trouble with the 'make a copy of the data' part?

Murtan 317 Practically a Master Poster

Well, I personally prefer to help with code that will at least compile...

Your original lines 36-39:

status = fscanf(filep, "%d%d%d%d", measuredp->site_id_num
	measuredp->wind_speed
	measuredp->day_of_month
	measuredp->temperature;

are missing the closing ')' for the function call and the ',' separating the arguments.

What dragon was referring to was that with your previous data structure, all of those parameters were arrays which made them implied pointers for the function.

If you make the changes to the data structure he recommended (and I agree with him -- no surprise there) you need to turn these into pointers here so fscanf can fill them in.

status = fscanf(filep, "%d%d%d%d", 
		&measuredp->site_id_num,
		&measuredp->wind_speed,
		&measuredp->day_of_month,
		&measuredp->temperature );
Murtan 317 Practically a Master Poster

I'm almost certain you have to make a copy of the data to do what you're trying to do.

Depending on the database and the size thereof, attempting to load the entire database into an array might not be your wisest design decision.

Here are a few questions to help evaluate the design:

How much data are we talking about?

Do you have enough memory to store it all?

What are you going to do with the data once it is in the array?

What is the real benefit to having the data in the array versus just accessing the data in the database when you need it?

Will this database ever be used in a multi-user environment where another user might be making changes to the data while you have it in your array?

Murtan 317 Practically a Master Poster

You aren't going to check each row/column set...this function will be very much like your 'check for a winner' function that finds when someone wins.

You need to go through all of the possible wins looking for one that is 'almost' there. A lot of your win check and partial win check code would have been easier if you had 'flattened' the game board. As I mentioned on a couple of other Tic-Tac-Toe threads (I think one was yours) just because the board is displayed as a 3 x 3 matrix does NOT mean you have to store it that way.

Regardless, if you had an array (or list) of the possible ways to win, the check for a real winner code could use them to find a winner, and the check for an almost winner could use the same list.

// presuming that ax, ay, bx, by, cx and cy are all integers
// and have been initialized to a set of coordinates for a winning path

// presuming this function has access to ticTac -- the board array

if ((ticTac[ax][ay] == ticTax[bx][by]) && (ticTac[cx][cy] == BLANK))
    // cx,cy either wins or blocks a win
else if ((ticTac[ax][ay] == ticTax[cx][cy]) && (ticTac[bx][by] == BLANK))
    // bx,by either wins or blocks a win
else if ((ticTac[bx][by] == ticTax[cx][cy]) && (ticTac[ax][ay] == BLANK))
    // ax,ay either wins or blocks a win

If the board were 'flat' then the same code would look like:

// presuming that a, …
Murtan 317 Practically a Master Poster

Well, if you check for the winner after every move, the only one that could have won would have been the last one to make a move.

Could you pass a string to the check win to tell which player it is checking for?

Or could check win return true or false (without printing) and let the code that called check win display the outcome?

Murtan 317 Practically a Master Poster

You mention srand() but I don't see where you call it...

Take a peek at this and see if it gives you any ideas.

Murtan 317 Practically a Master Poster

@idgeza
What is it doing differently from what you want or expect?

If it missing the B2 file, you need to add a write to the last B2 file after the 'big' loop completes. The write will be almost identical to the one inside the big loop. I would place it after you close ofDva

@jawadmardan
If you have a question and want an answer, put it in it's own thread, don't post it in a thread unrelated to your question.

Murtan 317 Practically a Master Poster

It has NEVER been my intent to write the code for you, and if I did, it would all be to one file as I discussed previously. If you want the output in multiple files, you'll have to do the work.

Regarding the datavec_C files, I was hoping for a clearer explanation of where the data sets come from...if they are the summary of the matching datavec_A files, then they will be written in the same area of code where the datavec_B files are.

Murtan 317 Practically a Master Poster

a = (rand() % 3) - 1; generates numbers in the range -1 to 1, is that what you intended?

Murtan 317 Practically a Master Poster

Not sure what you're asking about the first code block.

In the second code block, lines 10 and 16 (where you set and output cosangle) need to be past line 46 (where dvaIndexLast = dvaIndex)

And after the 'big loop' ends, we will need to output the histogram data again (datavec_B files), before the data is deleted on line 57.
It might make sense to write a function to output the histogram data to a stream. It might also make sense to have that function (or another that uses it) generate the filename and open the stream as well. Then we could call that function from the two places we write the file.

Did you want multiple datavec_C files? Explain the difference in content between datavec_C1 and datavec_C2

Murtan 317 Practically a Master Poster

At first glance, I thought the first code you posted showed the data going to two files at once (if i < 100), but then I noticed the else (on line 6 of the code below). As written, the first 100 lines would go in file 1, the next 100 lines in file 2.

if ( i >=0 && i<100 ){

				f1 << cosangle[i] << endl;

			}
			else if ( i >=0 && i<200 ){

				f2 << cosangle[i] << endl;

			}
			else { 
			cout << "There is something wrong..." << endl;
			}

The key limitation with the above method is that all of the files have to be open at once and open files is a potentially limited resource. (If you wanted 3 data files x 10 sets, you have to have 30 files open before you start.)

Regarding the last code you posted, that is how I first anticipated the file output looking. The following discussion gets into how I would go about having separate datavec_B files as well.

Regarding the datavec_B files. If you want one for each datavec_A file that only has the data for that file, you would add the output and reset for the histogram data before opening the next datavec_A file.

if (dvaIndex != dvaIndexLast)
	{
		// Output anything necessary before we close the file
		// --- fill in anything you think is appropriate

		// close the file we're done with this part
		ofDva.close();

		// *** You can output and …
Murtan 317 Practically a Master Poster

Ok, first, based on your answers to the questions, the file sizes represented do NOT warrant the work and/or effort to split the files up. In fact, if you're going to use this data for anything useful on any kind of recurring basis, I suspect you'll regret splitting the files.

I'll still help you split the output if you're sure you want to, but it doesn't make any sense to me.

Your answers to the questions were all fine until you got to the last one. Your answer to it is inconsistent with your previous answers.

The first set of answers seem to indicate a desire to split the data into equal size files. The last answer seems to indicate that you want the data from the first record (line 0) in all ten output files.

Which is the way you really want it to work? (You pretty much need to pick one unless you're planning to give the user a way to make a choice.)

In the discussion of hbins, you seem to set a maximum at 200 bins (which would be 201 lines with the header line), but you also seem to still indicate that there would be more than one file.

Do you plan to repeat the data in all of the files, or would the files contain only the binning data for the entries in the matching data file? (i.e. dataVec_B1 would contain binning data for ONLY the data in …

Murtan 317 Practically a Master Poster

It would depend on how smart you want the computer to play. The smarter you want the computer to be, the more work it will be.

You will likely end up adding a function that will 'make a move' like the player1() and player2() do. A simple implementation for the function might be to randomly generate coordinates until an available space was located.

A more complex algorigthm would be multi-part, possibly something like the following:

  • look to see if the computer can win on this move, if so, make that move and win.
  • look to see if the player can win on their next move, if so block that move.
  • randomly select another location

The most complex algorithm would replace the last 'randomly select a location' with a make the 'best' move instead.

Murtan 317 Practically a Master Poster

I don't see any answers to the questions. I'll quote the questions again here, but I will not reply to this thread again unless you answer them:

Your current code has N (the limit for the big loop) set at 1000, what do you expect the maximum value to be?

Your current code has hbins (the number of bins in the histogram) set at 10, what do you expect the maximum value to be?

In your first code, the file "datavecA.dat" contained 1000 lines of data. Each line of data consisted of a single value. The value was a double. If you break the file up into parts, what do you expect to be the maximum number of lines in each part?

In your first code, the file "datavecB.dat" contained a title line and 10 data lines. The ten data lines contained four double values, preceded by a space and separated by two tabs each. If you break the file up into parts, what do you expect to be the maximum number of lines in each part?

In your next-to-the-last code you appeared to be creating a "datavecC.dat" file that contained the single number that was the sum of 10,000 other values. If this file is to be included, what do you expect the maximum number of lines in this file to be?

Regarding your last post, did you even bother to read the code I posted?

// calculate the current dvaIndex from the loop index
	// change this …
Murtan 317 Practically a Master Poster

You're iterating too far.

The element indexed by cnt wasn't fully read.

On Line 25 the loop limit should be i < cnt not i <= cnt