Murtan 317 Practically a Master Poster

Ok, I was going to compare the strings, but I decided that was inefficient so I switched to integers.

// I'm using strings
#include <string>
// I'm using stringstreams
#include <sstream>

// We need to declare the output stream we will write from inside the loop and open the file for output
ofstream ofDva("datavec_A1.dat");

// Two integers for the current datavecA index and the last datavecA index
int dvaIndex = 1;
int dvaIndexLast = dvaIndex;

// Now for the loop
for (i = 0; i < N; i++)
{
	// calculate the current dvaIndex from the loop index
	// change this formula as required to determine the maximum number of lines per file
	// or based on the number of parts you want.
	dvaIndex = 1 + i / 200;
	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();

		// generate the new filename
		ostringstream tfn;
		tfn << "datavec_A" << dvaIndex << ".dat";
		// open the file
		ofDva.open(tfn.str().c_str());
	}
	dvaIndexLast = dvaIndex;

	// The rest of the big loop goes here

	// including the output line
	ofDva << cosangle[i] << endl;

	// and the histogram binning lines
}

// we're done with the loop
// close the last file we had open
ofDva.close();
Murtan 317 Practically a Master Poster

You appear to be having an extremely difficult time following what I thought were simple directions. I am apparently failing to communicate.

Let's get back to basics first.

Questions -- please answer them all:

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?

Back to commentary

The above questions are intended to justify the …

Murtan 317 Practically a Master Poster

First, let me repeat again, at the sizes you are currently configured for, breaking the output up into multiple files is unwarranted.

If we're only at the testing level now (with N at 100 and hbins at 10) and the numbers are going to get a lot larger then it might be worth the effort.

int nextindex = 0;
for (int ii = 1; ii <= numberofparts; ii++)
{
   // build the filename to open
   // open the file here
   int part_end_index = (ii * N) / numberofparts;
   for (; nextindex < part_end_index; nextindex++)
   {
      // output the data for [nextindex]
   }
   // close the file
}

The above code (which has a few pieces for you to work on still) was intended to replace the output routine that I had following the main loop (in the example where I moved the output code from around and inside the big loop).

This code was only intended to handle the vecA part of the output, but if you need to break up the vecB files (the data histogram) you could apply a similar routine, but add the output fo the file header just after where the file is opened.

I'm not sure what the intent of the vecC file is, but you appear to be only writing one number in it.

Murtan 317 Practically a Master Poster

You need to seek before you read (saw you have that), but you need to seek to the same location before writing (by default, the act of reading moved the file pointer).

//Insde main:
     else if(choice==2)
     {
       cout<<"\nEnter the sl.no. of the book :";
       cin>>bno;
       int loc=(bno-1)*(sizeof(books));
       // seek for reading
       file.seekg(loc);
       file.read((char*)&B,sizeof(books));
       B.update();
       // seek for writing
       file.seekp(loc); 
       file.write((char*)&B,sizeof(books));
       file.seekp(0,ios::end);
     }
abhaymv commented: Thank you again! +1
Murtan 317 Practically a Master Poster

I thought I showed you what I recommended.

I thought I showed you that you could take the output out of the big loop.

The goal would be not to repeat the same code for as many times as you have data files.

If you insist on doing it that way, at least try to turn some of it into a function.

You can't output the histogram data until you have processed all of the data in the main loop.

You can't write part of the histogram data out if you've only processed part of the data.

If you're going to open and close the file for each iteration, you're going to have to open the file in append mode to add to the end of the file, but then somewhere you have to either delete the file before you output, or open the file normally to clear it out.

Murtan 317 Practically a Master Poster

I was thinking something like this, but I would much rather have seen you try something than just give it to you. Demonstrate effort, you get lots more help.

int nextindex = 0;
for (int ii = 1; ii <= numberofparts; ii++)
{
   // build the filename to open
   // open the file here
   int part_end_index = (ii * N) / numberofparts;
   for (; nextindex < part_end_index; nextindex++)
   {
      // output the data for [nextindex]
   }
   // close the file
}
Murtan 317 Practically a Master Poster

I understood what you said you wanted to do.

Apparently you didn't understand what I was recommending.

Right now you have something like this:

ofstream ofile;
        ofile.open("datavecA.dat");

	for (i = 0; i < N; i++) 
	{ 
		// I skipped some of your stuff here...
		cosangle[i] = vec_angle(vec0,vec);
	 
		ofile << cosangle[i] << endl;

		// histogram data calculated from all 100 entries into 10 bins		
		int bin=(int) ((cosangle[i]-hmin)/(hmax-hmin)*hbins);
		if ( bin<0 ) bin=0;
		if ( bin>hbins-1 ) bin=hbins-1;
		h[bin]++;

		// I skipped another line or two here...
    	 }  
	ofile.close();

Would you agree that the file would have the same contents if the above code was written as:

for (i = 0; i < N; i++) 
	{ 
		// I skipped some of your stuff here...
		cosangle[i] = vec_angle(vec0,vec);
	 
		// histogram data calculated from all 100 entries into 10 bins		
		int bin=(int) ((cosangle[i]-hmin)/(hmax-hmin)*hbins);
		if ( bin<0 ) bin=0;
		if ( bin>hbins-1 ) bin=hbins-1;
		h[bin]++;

		// I skipped another line or two here...
    	 }  

	ofstream ofile;
        ofile.open("datavecA.dat");
	for (i = 0; i < N; i++) 
		ofile << cosangle[i] << endl;
	ofile.close();

Now that last file write could be broken up into multiple pieces (as many as you care to) fairly easily without having to 'muck up' the main loop. (Note however that each N only adds one line with a single number -- 100 lines is still a pretty small file.)

The histogram data really can't be written at all until the main loop is complete either, and it doesn't …

Murtan 317 Practically a Master Poster

I think your problem is that you don't read the records from the file when you're making changes to them.

For example if the first thing I did after starting the program was to check-out or check-in a book, I select menu choice 2 and this is the code:

else if(choice==2)
     {
       cout<<"\nEnter the sl.no. of the book :";
       cin>>bno;
       int loc=(bno-1)*(sizeof(books));
       file.seekp(loc);
       B.update();
       file.write((char*)&B,sizeof(B));
       file.seekp(0,ios::end);
     }

You seek to the position but don't read the data.
Then you update whatever the B class had in memory.
Then you write out the contents of the B class.

It would probably be obvious if the check-out/check-in process displayed the name of book and the number of copies you thought it had.

Unless you're running with a debugger (and you'd probably not be asking the same questions if you were) add more printing (at least for debugging, you can comment it out later if you don't want it in the final version). Knowing what your program is doing and understanding why it is doing what it is are the keys to making it all work.

Here's a personal style comment, feel free to ignore it:
Which is easier to read?

cout<<"\n1.Add new book.\n2.Issue/return book.\n3.Edit book info.\n4.Show book info.\n5.Add new user.\n6.Update user info.\n7.View user info.\n8.Delete data base .\n9.Aboout\n10.quit.\nEnter your choice: ";

or (this works because the compiler merges adjacent strings)

cout<<"\n"
          "1.Add new book.\n"
          "2.Issue/return book.\n"
          "3.Edit book info.\n"
          "4.Show book info.\n"
          "5.Add …
Murtan 317 Practically a Master Poster

When asking for help, please describe the symptoms you do see (if any).

For debugging purposes, you should add some print statements to your code to confirm that you are getting the data you expect, where you expect it and for progress messages so you can tell where you stopped at if your program doesn't complete.

If this was c++ code it wouldn't compile (the return value on line 115 does not match the specified return type on line 88)

Your wordA and endWordA functions do not quite use the same algorithm.

The for statement on line 70 in checkword will likely cause an infinite loop. The test condition should be for word1[x] even if you fixed that, the function does not do what you need it to do. It needs to form a representation of the letters that are in the word, regardless of order or frequency. The algorithm you have works for order, but not for frequency.

If you're not attached to them, changing the prototype for wordA might allow you to actually do what you're attempting and return where the word ended at the same time.

int nextWord(char sentence[80], int startx, char wordfound[80]);

Where it will return where the word ended and fill the wordfound array with the word it finds.


A 'better' overall algorithm might be:

  • force the sentence to upper or lower case
    I don't see where you have to preserve the case of …
Murtan 317 Practically a Master Poster

200 lines of code is not unreasonable to post, you should just have posted it in code tags. (There are lot of people that won't download code. I don't do it very often.)

The "vecA" files would be fairly straight forward to do after the loop that does the calculations, it is just printing elements from the cosangle array. I would wrap a four pass for loop around code that would output 1/4th of the file at a time.

The "vecB" file only have 10 lines at present is there any point to splitting them into 4 files? If so, you could do it in a similar fashion to what I suggested above.

If you have any trouble with the above, make an effort at writing it and post the code (in code tags) along with a description of the problem and I'll help you figure it out.

When posting c++ code, please use c++ code tags

Murtan 317 Practically a Master Poster

Posting the code (in code tags) would have saved a lot of description of 'how you solved' the problem and given us a chance to actually help you.

I think I understand the symptoms of the problem fairly well (and that's a good thing to include when you're asking for help) but I don't understand what the code is doing or which part of the code you think is failing.

So post at least the part you think is having trouble, but the whole function involved would be better, and depending on the size and complexity of the file and/or the other parts of the file that the function interacts with, the entire file might not be out of line.

Murtan 317 Practically a Master Poster

I wouldn't use multi-threading in this type of application.

You might look at using something from the _spawn family of functions using the _P_NOWAIT setting in place of your system() call. They start child programs, but do not wait for them to complete.

Murtan 317 Practically a Master Poster

I don't see anything obvious about the login...maybe you could describe the problem you're having better?

As not all of the code required to validate the login is shown, I'm presuming that all of the variable declarations are ok and that the user input for the login and password don't have problems.

I'm not sure why you have the while loop that starts on line 5 in your first code fragment. You never loop as the if statement either causes the while to break (in the true clause) or return (in the else clause).

I didn't really look at the second code fragment, but I did look at the listed contents for BankData.txt and it appeared to be ok.

Murtan 317 Practically a Master Poster

Specific comments on your code posting:

You still have not added any debug prints to track your way through your program. From your comments about how your program runs, I'm presuming that you either don't have access to or don't know how to use a debugger.

Line 25, 35 and 93 should all start at index 0 and stop BEFORE 8

Something like:

for (int ii = 0; ii < 8; ii++)

Style comment: I always use at least doubled letters for my for loop indexes, it makes them LOTS easier to see and search for.

Second style comment: I used a define in place of the 8 in your code. That way if it ever had to change it to say to 9 or 10, it would be easy and all the uses of it would remain consistent.

Lines 95 and 97 are attempting to read data that does not exist in the data file.

Line 21 has a typo that should produce an infinite loop if you have any records

It currently reads:
for the integer i starting from zero, continuing while one is less than the count, incrementing i each pass

it should read:
for the integer i starting from zero, continuing while i is less than the count, incrementing i each pass

Murtan 317 Practically a Master Poster

I have to agree with Dave...it almost looks like you aren't trying.

I took your last posted code and did the following:

  • modified it to support the number of grades you actually have
    (Which has been mentioned more than once.)
  • Used getline(stream, string) and istringstream to parse the input
  • Corrected array indexes to start from zero and to stop at size -1
    (something declared as int grade[5] has elements grade[0] through grade[4])
  • Changed the print function to keep data aligned and on one row
    (It wasn't as pretty before I did)
  • Actually called studAvg() to calculate the student's average grade

There might have been a little more, I didn't take notes as I fixed it, this was generated from memory.

I produced the following output:

0 Benway      32998 Eileen      76  98  80  69  75  94  77  95  83.0  B
 1 Berling     15246 Danielle    85  64   0  75  69   0  54  85  54.0  F
 2 Burr        50838 Jermiah     83  84  94  90  77  73  72  63  79.5  B
 3 Connors     77921 Sarah       52  58  88  63  61  65  78  78  67.9  C
 4 Cooper      24609 Camille     62  93  92  72  58  76  57  66  72.0  C
 5 Denaro      10364 Tony        73  85  55  72  68  91  55  89  73.5  C
 6 Ecklord     44520 Ryan         0  61  56  86  98  98  59  83  67.6  D
 7 Flores      58751 Jose        58  80   0  74  87  95  96  69  69.9  C
 8 Galotti     18140 Salvator …
Murtan 317 Practically a Master Poster

There may be design issues here...

The base class can declare any function it likes as pure virtual, but all of the child classes must implement it using the same concrete argument list.

If your generic list contained instances derived from the base class, how would someone using the list have any idea about which kind of object it was? (I thought the idea was to make it so users of the list could treat them all the same.)

If you need different behavior (function calls) then you need different types and the caller needs to know what kind it is. (You're back to looking at the type of each item and handling it appropriately.)

Murtan 317 Practically a Master Poster

I don't see anything obvious about why your code would just stop without exiting.

I guess your next step is to either run the program in the debugger (if you have one) or to add debug print statements to the code so you can see how far it gets.

Murtan 317 Practically a Master Poster

So your array class is intended to transparently represent the result of possibly many allocations as a single array. Due to the HUGE size of the array, it is absolutely CRITICAL that the allocation take as little time as possible.

Also, if your 'example' allocation which wants to allocate 198,145,029,864,623,361,045,926,400 array entries is even vaguely accurate, you have a much larger problem. Even if the allocation were only for 1 byte each it would take 198,145,029 terabytes (if I did the math right). I don't think you'll find that much memory (or even disk space) in any computer I've ever heard of.

If your example was 'over eager' and I were in your situation right now, I'd be looking at malloc (if it's available to you and the array will contain a 'standard' C type) but it would be a significant change from your current structure.

If your array won't fit in memory, you could end up virtualizing it to disk...but if you think calling constructors on memory was slow, disk access will not be a pleasant surprise.

I've asked questions several time attempting to get some real scope on the problem. I'm not putting any more of MY time into this unless you can show me hard data that its worth more than I've already invested. As I stated before, speed is always important, but if you're not careful, you'll spend more man-hours on speed improvements than you would ever save.

Questions I've asked …

Murtan 317 Practically a Master Poster

If you don't have a compile error, you can add debug print statements (or run in a debugger) to determine how far into your program it gets.

I'd at least add a print before you read the id with the record number you're on. And maybe a print of the first and last name to confirm you're staying aligned with your data. (I don't think you are in the code I see.)

Murtan 317 Practically a Master Poster

I don't see much point in allocating all available memory unless you're trying to stress-test another application, and if you're stress testing, I'm not sure what the hurry is.

I'm pretty sure you can override new to create custom allocators, but because this is a template, we don't know what we're allocating.

The language requires that the constructor be called for all of the array elements (I'm pretty sure this is why the new for the array is slower).

You might try using malloc to allocate the memory, you can allocate largish chunks and even if the memory is initialized to zero, it won't be calling multiple constructors.

I don't think your line 19 will compile, the xarray constructor I can see will accept either 0 or 1 argument. Your call is providing 2.

Add some debug:
* how long does it take to perform the first allocation?
* how big was the first allocation?
* how long does it take to perform the last allocation?
* how big was the last allocation?
* how long did it take overall for all of the allocations?

As I don't see that you're actually planning to use the data at all, why did you bother making a template with built-in recursive allocation, why not just a function to repeatedly allocate memory??

Murtan 317 Practically a Master Poster

if you're getting a compile error, would it trouble you too much to include the error?

Murtan 317 Practically a Master Poster

If the data is large enough, I suppose it can take a while, but I've done some fairly large data sets and never really felt the need to 'speed up' allocation.

How much data are you allocating?

Have you measured how long it takes, if so how long does it take?

How often do you make this allocation?

(Speed is always important, but if you're not careful, you'll spend more man-hours on speed improvements than you would ever save.)

Murtan 317 Practically a Master Poster

The data would only be somewhat harder to access in a SQL database than in an access database if you can get access to the file.

That's one of the benefits of a true SQL Server, your application talks to the SQL Sever application and you don't have to have access to the data file. The computer with the data file could be physically secured and wouldn't have to share the file for others.

If you can't secure the file, (and maybe even if you can,) you're going to have to secure the data, probably using a form of encryption. If this is the route you take, you will have to put extra effort into securing the encryption (decryption) keys. (I don't recall if SQL Server has any direct support for ecrypted fields.)

Secondarily, the data you want to secure would appear to be readily available to the user at the terminal. Should the data be secured there as well? Is the data your trying to secure being printed on any forms? (Say insurance claims or something?)

I think some of the data you have may be protected by HIPAA and I'm not familiar with the standards. If you're writing the program, you should probably be familiar with the requirements and make sure that you're supporting them as well.

Murtan 317 Practically a Master Poster

Unless I'm mistaken, your code won't compile.

The first problem is that the compiler doesn't like you to declare the size of an array at runtime, it wasn't to know how big the array will be at compile time. (You can get around that by using an array that you allocate, but a 2 dimensional array is somewhat harder to allocate.)

On line 25 you accept input into the array as if it is single dimensional, but then on line 30 you attempt to output as if it had two dimensions. Line 30 appears to be outputting an indexed element, but there are no surrounding loops.

You will need to treat the array in the same fashion everywhere you use it.

It is also possible to 'emulate' a 2d array with a larger 1d array, but that might disagree with the spec (assignment) you are working on.

Murtan 317 Practically a Master Poster

and you forgot the [code]

[/code] around your code so that it is highlighted and has line numbers.

(oops didn't see the previous post -- sorry)

Murtan 317 Practically a Master Poster

You need to associate a method with the button's "on click" event.

The code in the method will need to generate the textbox.

If you want more detailed help you're going to need to tell us more about your code environment, and preferably show us some code to show that you're trying to solve the problem.

Murtan 317 Practically a Master Poster

.mdf is just a file extension, in a database context, it is usually associated with SQL Server. The file doesn't have any intrinsic support for anything. It's the database libraries that handle the file.

You stated that Access has 'lousy security' which I won't argue, but what level of security do you really need?

The level of security relates to how critical the information is and what you need to protect it from. Do you need to secure the data against reading? Against modification? Something else?

What is the impact (cost?) if the data is not secured?

What value is there to a third party to access the data?

The greater the impact (and/or the greater the value) the more that you will need to do to secure the data. If the impact and value are low, then you don't have to try very hard.

Murtan 317 Practically a Master Poster

Also, when posting your code for us to look at, please use code tags:

[code]

// Your code goes here

[/code]

It makes the code MUCH easier to read. (There are several people that won't even look at your problem unless you use code tags.)

Murtan 317 Practically a Master Poster

You need to associate a method with the button's "on click" event.

The code in the method will need to generate the textbox.

(Did you mean a message box?)

If you want more detailed help you're going to need to tell us more about your code environment, and preferably show us some code to show that you're trying to solve the problem.

Murtan 317 Practically a Master Poster

His line 12 should have been ++cnt; Though I agree with a previous poster that you have 8 grades, and do not have an average or a letter grade in your input file, which makes his sample code flawed as it tries to read the average and grade.

Murtan 317 Practically a Master Poster

Why don't you want the memory set to zero?

Are you trying to extract some 'previous' value from the memory?

Murtan 317 Practically a Master Poster

It would be possible to share the file across a network. However whether or not multiple people can use your application to access it at one time would depend on the file locking performed either by your code, or the library you use.

If your application or library supports file locking, it can either support whole-file locking or locking for part of the file. How your application / library handle the failures (due to someone else having a lock) would determine what if any error messages the user might see.

Murtan 317 Practically a Master Poster

if you're using code tags, you can leave the spaces where they are in the code. (don't add the periods)

The intent of code tags is to provide syntax highlighting, line numbers and to preserve white-space.

The 'code' you have posted (when I replace the '.'s with ' 's) won't even start to run...it has an indentation error (you seem to like them).


If you want help with your original progam's speed, why don't you post what you're trying to run (in code tags) and we can look at it.

If you have a new question on a new topic, you should start a new thread.

Murtan 317 Practically a Master Poster

If you're wanting to support multiple users across a network, you're probably going to want more of a real database, whether your users have to install it manually or not.

Murtan 317 Practically a Master Poster

If you haven't gotten the hint yet...indentation (leading white-space) is CRITICAL to python programs.

In the case of the import os line...it should be all the way to the left...there should be no white-space characters in front of it.

Just like it was in the code I posted.

If you think you already have it to the left, paste ALL of your code here...(inside code tags)

[code=python] # Your code here

[/code]

Murtan 317 Practically a Master Poster

The compiler requires that the 'interface' function1() declared in the base class have a concrete argument list.

What kind of abstraction do you think it needs?

Could that abstraction be implemented with another base class?

If the function call is abstract, how will the caller know what to pass the abstraction?

Murtan 317 Practically a Master Poster

The reason you lose the first character of the title is because the first loop is different from the second and third loop. Look at the difference yourself and see if you can figure it out. You're actually losing all but the last character of the title, but in this case keeping the last means only the first is missing.

If you ever attempted to add spaces, I haven't seen it in your code. Show us where and how you tried to add spaces and it failed.

You don't need to pass the string lengths into concat, if it needs them it can calculate them just like you did. If you use an algorithm that looks for the character that marks the end of the string, it may not need need to know how many characters are in the string anyway.

Murtan 317 Practically a Master Poster

I took your code and touched it up a bit...

import os

# put this part back if you're really attached to changing directories
#while True:
    #targetfolder = raw_input('Enter target folder to search:\n')
    #if isdir (targetfolder):
        #os.chdir(targetfolder)
        #break
    
targetfile = raw_input('Enter file to search:\n')
infile = open(targetfile)

searchword = raw_input('Enter string to search for::\n')

found = False
for line in infile:
    if searchword in line:
        print line
        found = True

if not found:
    print "Searchword %s not found in file %s" % (searchword, targetfile)
Murtan 317 Practically a Master Poster

What about posting the code in code tags so we can see the indents and have a chance at being able to help?

Murtan 317 Practically a Master Poster

Templates require the users to see all of the member functions. You can't have the methods 'hidden' in a c++ file.

If the code creating the instance of the template doesn't "see" the method, the method does not get implemented.

This is due to the way templates are implemented. They are not implemented as generic methods that work for any type, they are implemented as specific methods for the types identified.

If you had a tree with two different argument types (say IntBinaryTree<foo> and IntBinaryTree<goo>) there must be an insert node defined for each...(IntBinaryTree<foo>::insertNode() and IntBinaryTree<goo>::insertNode()) they will not find or use a 'generic' insertNode().

(It is possible to have the template derive from an actual base class if there are methods that can actually operate without the type, and the implementation for the base class methods would be 'hidden' in a cpp file and linked to the code.

Murtan 317 Practically a Master Poster

My original thought was that you would track the current editor as a frmEditor in your code. Upon further thought and contemplation (see reading the manual) I have revised my opinion.

We can use this.ActiveMdiChild but it is of type Form and not the class we want (frmEditor). We need to 'cast' it to our type so we can call our method (as our method is not defined in the Form class).

We can use the c# 'as' to make the conversion for us, without throwing an exception if the cast fails. (If the cast fails, as returns null.)

frmEditor currentEditor = this.ActiveMdiChild as frmEditor;
if (currentEditor != null)
    currentEditor.method(arguments);
Murtan 317 Practically a Master Poster

When posting python code, please use python code tags

You have to post your code with code tags so we can see the indents.

And as this is your second thread on the same topic and you didn't answer my question in the first...is searching a single file what the assignment was supposed to do?

Murtan 317 Practically a Master Poster

You're losing the first character of the full name inside the first for loop (of concat()). The second and third loops add each character to what was in fullname, but the first loop assigns each character to fullname. The second character in title overwrites the first. (If the title were more characters long, you would be missing more.)

As to the spaces that are missing, where did you put them in?

Maybe you should just add a space to fullname between the first and second loops and again between the second and third?

Murtan 317 Practically a Master Poster

The basic code you were given declares the array and then passes it to the functions you are supposed to write.

Murtan 317 Practically a Master Poster

So you just want to output the percentage calculation for heads and tails?

Wouldn't you just divide the number collected by the total sample size?

Murtan 317 Practically a Master Poster

I don't think I understand the second example...

input: i have 2 bananas and 3 oranges
print: 1+2+3= 6

Where'd the 1 come from?

Code comments:

line 6:

data = input("Please enter a string\n")

Should use raw_input to get string data.

You appear to be dividing the characters up based on whether or not they are digits, seems like a sound idea. Where are you building the multi-digit numbers?

Where are you building the sum of the numbers you've found?

You can iterate all of the characters in a string and only output the digits with something like:

digits = "0123456789"
for x in data:
    if x in digits:
        print x

I don't know if that make your problem any easier, but I find it easier to read and understand.

Murtan 317 Practically a Master Poster

Based on what you have there, I suspect you're supposed to write the two functions:

int empty_array_insert(int[], int);
void display_in_reverse(int[], int);

Murtan 317 Practically a Master Poster

Assuming that your sort works...

if (n[0] == n[1] && n[3] == n[4] && (n[2] == n[1] || n[2] == n[3]))
Murtan 317 Practically a Master Poster

That makes sense I suppose, but if it is a MDI container, and there is an active child window, when the user clicks the menu on the main form, does that make the child window lose focus? If it loses focus would using this.ActiveMdiChild work?

Also...I'm a little lost about why you would call a function in that way, it seems like you are doing it backwards... like...

frmEditor is the location of the method I want to run, so in order to run a method there I need to call the method by making a new object and then assigning that object a value that is never used anywhere? That's what it looks like you are doing. frmEditor currentEditor = this.activeEditor. so what is currentEditor and activeEditor? other than within the if statement where you reference currentEditor.method(), why would you bother doing frmEditor currentEditor = this.activeEditor. ...couldn't you just say frmEditor.method()...it seems to me that it would be the same? Maybe I'm thinking of it wrong?

Clicking on the menu or toolbar in an MDI parent does not change the MDIChild focus. (Note that it is tracking an MDI focus, the menu or tool bar might have the event focus, but the MDI child focus was not changed.)

You have to have an instance to call a method. If you have 3 editors open, which one would you mean if you say frmEditor.method() ?

The frmEditor currentEditor = this.activeEditor; makes a copy of a reference that the …

Murtan 317 Practically a Master Poster

I agree about the while in main, but were you trying to stop when the board was full?

You can't look at a single location to determine if the board is full.

Just another comment or two for future projects (I wouldn't re-design this one now):

Just because the board is displayed as 3 x 3 on the screen, does not require you to maintain it as 3 x 3 in memory.

There are several functions which might be simplified if you had a single array with 9 elements. For example, your winner check for rows if you had a single array it would look like:

if ( (ticTac[0] == ticTac[1] && ticTac[1] == ticTac[2]) ||
     (ticTac[3] == ticTac[4] && ticTac[4] == ticTac[5]) ||
     (ticTac[6] == ticTac[7] && ticTac[7] == ticTac[8]) )
{
   // Horizontal winner
}

It would also allow you to replace most (if not all) of your nested for loops with a single loop.

It would also make it easier to allow the user to enter 1 - 9 to select the spot they want instead of using two coordinates.

When I wrote one of these last, I used the BLANK concept to know where the available spots were, but my board printer function would see the BLANK and output the index number for the box instead of the blank. That put all of the numbers where you can see them until they are replaced with an X or O.