jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What's the error that you are getting? Are there really only 5 records in the file?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No no, while is actually preferred. You can use your cin >> s1.name as the condition for the while loop.

Great on the string changes, but now the whole string will be stored in that variable, so you don't need 64 of them in one struct.

Also remember to make an array of structs as each line in the data file will have its own. As it stands you'd overwrite your variables each time.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try taking the call out of InitializeComponent as I'm not sure it's considered part of myControl1. Try calling just plain Init() in the constructor of MyControl after InitializeComponent(). It's balking about that line because if Init() is not being called correctly the image is indeed going to be null.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would skip over the buffer completely.
Make name and color strings (e.g. string name; )
Create a loop and read:
myfile >> s1.name; //but see below, should be s1.name
myfile >> s1.color;
(get the int)
(get the other int)
then repeat this over and over again for all the lines of your file. So you should make an array of people actually.

Oh yeah, and qualify main() with int (e.g., int main() ).

shishio1014 commented: hes a good programmer +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What does that particular segment of your code look like (if you're able to post it)? MathBot sounds interesting -- combing netspace to solve random equations it encounters. ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You are not the first person that has posted here to deal with this problem. Do a search on the forums.

Hint, break the number that is input into pieces, going from largest to smallest. You probably know those pieces well, or if you don't look the system up on Wikipedia, it's a nice article.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Couple of things right off the bat... #include <iostream> the one with the .h is potentially a prestandard version. main() should return an int (and pop a return 0; at the end of main.

If you can I would include <string> and use that instead of the char array. If you can't we can work around it. That way with the string you can read right into it (you can use getline but with the mixed strings and ints in your data you're probably better of using myfile >> . See this and the related pages about fstream.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is really a C program, which should be in the C forum. You wanted to stay on "AT&T Boulevard" but take a left on Ritchie Street instead of taking a right on to Stroustrup Lane.

Try dropping a getchar(); statement at the end of the program before your return statement.

Also please use code tags next time. //your code here

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Reported.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is it possible to use a for loop and compare the user input to the structure like if (userinput = s1.id)?

Yes with == ( if you have a pointer to the struct it would be userinput ==mystruct->id)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just to clarify, are you reading your data into the program or is the user typing it in? However, in reality your struct should be the same either way you do it. OL# can be a string member of your struct, or you could make it an int member and strip the OL out of the string you read in and turn the remainder into an integer.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Welcome. Please read the following http://www.daniweb.com/forums/announcement8-2.html
After you've looked it over and brought some code to the table, we'd be happy to help you with it.

Salem commented: Well said! +17
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Once I found your code and that it included zlib.h I googled for that and got that googlebit.com site. The links within the code on there were nice I could work my way back up the source tree until I got it. Luckily it wasn't too far. Yeah, I googled OF also, but was disappointed (normally it is "smarter" about things like searching for C but it was ignoring () ).
I think I've seen something like this a really old code as I don't think prototypes were required in K+R C (I'm sure someone out there knows a lot more about that than I do).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's defined on line 166 of http://fxr.googlebit.com/source/lib/libz/zconf.h (same library different site) which is included in zlib.h which your file includes. It checks for this STDC value which I assume means whether the system supports standard C. It seems to expand to a prototype of the functions. I know precious little about *nix, but I was curious myself so hopefully that gives you a head start to find more info on it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Topi is on the right track I think. A portion of it has to do with your preprocessor directives. I've never seen one with a period in it and this is why I suppose. Most people use an underscore in place of the period (the convention is to name it after your header like you had done, but really it could be anything). So change those to NODE_H, DOUBLYLINKEDLIST_H etc.

NULL is something that is defined in a couple of the headers so it has to be in all caps. You need to include <iostream> for the NULL and the couts. Also you need to qualify cout one of 3 ways: either put std:: in front of it, std::cout, or put using std::cout; at the top of your file, or the last option put using namespace std; at the top of your file (which is the least favorable since you have to worry about all the names in that namespace conflicting with the code you've written.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Even if you are trying to defend the Creationist side (which I'm not really sure that you are) you are not doing it very cogently (whether it can be done cogently is another story). I think if you told me that the room was on fire I'd consider staying put.

You've inspired me to start toting my theory of the really tiny, really smart person that lives inside my computer processor. If only he/she had a more open mind about the logic I set out to implement.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Anyway, just try putting in, system("cls") at the bottom of your code, then run it.

No, not system("cls")
a) system() shouldn't be used and b) if anything would be system("pause") but don't use that either.

Read http://www.gidnetwork.com/b-61.html if you have doubts about that.

Or you can run your program .exe directly from the console and you won't have to worry about pausing. Change to yourprojdir\Debug

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put in a cin.get() at the end of your code (before return 0; )

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Select Win32 console project if you did not already. If you haven't create a new project for Win32 Console. Leave empty project unchecked and uncheck precompiled headers. See if any or all of that helps :) (Also make sure it built correctly with no errors, though it sounds like you were saying it did. It should say 1 succeeded 0 failed yada yada in the output window.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Do you have freedom in your class design that you could instantiate it within the Form1.h code and pass your form1 in as a parameter to the constructor? (or better yet whatever individual UI components you needed instead of the whole thing)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Compare your post to the following statement: My car only makes noise when it runs. Please help me fix it.

Indeed, moreso the equivalent of parking one's car diagonally across the repair bays at one's local service station and leaving it overnight.

(*the usual apologies for the bump but I had to get that one off my chest)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Under the Edit menu, Advanced, (uncheck) View White Space
CTRL-R,CTRL-W (first one, then the other or both at the same time)

(I remembered these from a similar setting in Word -- not the same keystrokes I don't think)

Excizted commented: Thanks for helping :) +1
Ancient Dragon commented: Very helpful -- I couldn't figure it out either. +25
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Firstly, use fgets to obtain your name string from the user. See this for a reference (it's a C++ site but it should be nearly the same).

Next look into ctype.h and there's a function tolower() that will help you if you don't know whether the text is in caps or not (you could test whether or not it was for each character but we can just transform the whole thing to lowercase). If you can't use that library, you can write your own very quickly, just add the correct amount to the char value (see ASCII table)

You can access the character n (0 to size-1) of the string in the ith (0 to size-1) structure as follows:
s1.name[n] so use tolower() on each char
as you compare that to yourstring[n]
where char * yourstring= "yourstringtomatch";
(put any bells, whistles,code to skip spaces etc in there too)
march your loop until you hit the null terminator in the string '\0' count the number of times they match, compare that to the length of the string and you're in business.

Post back if there are any issues.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I wouldn't say I "derived" it from anything, possibly because I don't quite understand the question.

That's totally my bad, I was not trying to be accusatory at all. I asked because I did it out with pencil and paper with a 2x2 case and at first got what you did, but I believe (and I still could be wrong lol) that it's only a function of columns.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you know the RowSize and colSize you can do this, but I see no point.
Using 2 for loops makes it more clear.

I suspect this is the kind of thing that becomes fodder in "My professor is better than yours" arguments as to who can produce these snazzy little tricks at parties. I'm unconvinced that this isn't an assignment.

I am unsure of the efficiency of my method, but I like to use (if using one loop is really a big deal; usually the choice is out of ease):

for(int i = 0; i < ROWS * COLS; i++)
{
    printf("%i ", arr[i/ROWS][i%COLS]);
}

I got something similar but did you use a square matrix to derive your result?
I was just trying to let the OP derive it him or herself but this will give him/her a boost in the right direction.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It is only when it's called darwins law

So if it's called Darwin's Law and then (simply as a pedagogical exercise) a scientist comes along and disproves it. Does that mean that it's immune to being disproved? No. Definitely not, it's not in the interest of truth or science to do so.
What you call something hardly matters in this context because these terms themselves (law, fact, theory, hypothesis) are all defined operationally.
All but the most trivial of scientific notions break down under some condition or another. What happens to the "Laws" of motion under near-light speed conditions? They break down and can be disproven. Does that now make them more open to excessive scrutiny? No-- because the theory says if I throw a ball straight up into the air (with some assumptions on what makes a ball and how perpendicular is straight and factoring in wind resistance) I have a pretty darned good idea of how long it's going to take to come down. The theory "works" but it's not universal. That doesn't mean it is not patent.
Evolution, mathematics, physics, chemistry all have very well established scientific communities. They themselves would acknowledge that they are not 100% correct (otherwise we could all take a long coffee break and go home for good). But, as the ideas, theories, etc. are evaluated, tested, and retested with the greatest degree of objectivity possible (I know there are exceptions to this) they get better and more accurate, phenomena …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Thanks for bringing it back! Happy Holidays Dani. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Write out what the loop would be printing for a 2x3 case

mat[0][0],        mat[0][1],      mat[0][2],     mat[1][0],    mat[1][1],          mat[1][2]
Your 2x3 counter would be 
     0                  1              2              3               4              5

So how do you get 0 to be [0][0], 1 to be [0][1], etc, 5 to be [1][2]

All else fails, pop it into a compiler and mess around with different combos.

Happy Holidays

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

... or I guess it's more that you can't store managed types in an unmanaged data structure at all.

http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/aa29a1a9-1ec9-49d9-8148-b83cfc272111

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

He's doing the managed code route so his choices are (AFAIK) limited to the .NET spectrum (I think he'd have to marshal in the STL container which I've never done but I've heard nothing good about). I've learned a bit of C# so it looks like stuff I've seen there but with a C++ twist to it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
using namespace System::Collections::Generic;       
//at the top of Form1.h

//here are the details of my little stub just to give you a ready test
//program (I don't know what your specific requirements for the
// LVI are so I just cobbled it into a button event.
ListViewItem ^ lvi = gcnew ListViewItem("test2");
Dictionary<String^,ListViewItem^> myDictionary = 
                                       gcnew Dictionary<String^,ListViewItem^>();
myDictionary.Add("test",lvi);
MessageBox::Show(myDictionary["test"]->Text);

Happy Holidays, hope this helped (I'm really seeing a lot of these C++/CLI specifics for the first time so it's a good experience all around).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

A large part of the problem (I cannot speak for your algorithm as of yet because I haven't been able to compile it without forcing) is that the math.h functions have require signatures that for the most part are float and double (and definitely not int), for example pow has the following prototypes (in C, there are a few others in C++)

#include <math.h>
	double 	pow (double x, double y)
	long 	powl (long double x, long double y)
	float 	powf (float x, float y)
(see  http://www.codecogs.com/d-ox/c/math.h/index.php to check what types of arguments they do take)

So what you need to do is make some design decisions as to whether you should cast these variables going into log, pow, etc. and/or explicitly put 10.0 instead of 10 etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I agree with firstPerson. However, I'm confused as to why this function marches along initializing some of the array members and then stops. You are asking it to "get" an element but returning a whole array. Unless you are doing some error checking that isn't evident in your code why wouldn't you use arr[row][col]? I'm just puzzled is all....

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

1.) Select the Form1.h [Design] tab in your project
2.) Click once on Form1 itself
3.) Go to the Properties Window (by default on the right side, but if you can't see it go to View/Other Windows/Properties Window
4.) In the properties window go to the little lightning bolt on the toolstrip (under Form1 System.Windows.Forms.Form
5.) Under behavior, double click the empty cell next to Form closing.

Now you'll have the proper event handler added and you can flesh out the method definition as you see fit.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See http://www.embedded.com/story/OEG20020429S0037 (it happens to be an embedded article but it still applies). When you are passing parameters to a function they are not guaranteed to be evaluated from left to right, right to left or any other order. I tried it on 2 different compilers (VC++ 2008 Express and gcc 3.4.2) and they gave 2 different answers so it's one of these "unspecified" kind of situations (from the article) and can't be relied upon. The best solution would be to perform the arithmetic for one step, print it out, step two, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The first backslash is an escape character, just like when you type \n you are escaping the character n and qualifying that it's a newline. So say you had for example mydir\name in your directory string (or any string for that matter) you then have to escape the \ character to tell it you just want the backslash.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Dude, the only thing you are doing is diluting and polluting your argument further (and believe me it wasn't much of anything to begin with). Science is a culture which seeks truth. Coming with membership in that culture is a great degree of responsibility to "play nice," contribute and demand coherent, objective experimental evidence for everything. This also means that if you don't understand something that doesn't mean it's not true.

If I didn't know any better I'd say you were trolling by making inflammatory statements but I'm not so sure. I think we would give you just as much (positive) attention if you were kicking around some ideas with merit.

Science for all the 99.99999999999999999999% of non-Einstein scientists is a lot of hard work for not a lot of reward. If you aspire for such greatness it's probably not going to just appear out of thin air.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm assuming you are using VC++ ? Go up to Project/"Your Proj Here Properties"/Configuration Properties/Debug/Command Arguments and put something for it to print out (separated by spaces).

If you're not using VC++ then just put some arguments after your exe name when you are running it. "myexe -parameter1 -parameter2" (you don't need the dashes in this case they're just for effect).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well more than likely your program is going to be doing some event driven stuff (reacting from a button getting clicked, text changed in a textbox).
Just to test out the concept put a button from the Toolbox onto your form (or whatever your gui need is),go over to Solution Explorer and there should be a tab saying Properties on the bottom of that window (else go to View/Properties Window). With the Form1.cs [Design] tab active and the button highlighted click on the lightning bolt in the toolbar. Go to the blank cell to the right of where it says click and double click it. You'll get an event handler button1_click (object sender, EventArgs e) placed into your code for you. Put whatever code you want associated with the click of the button in there(and you can call other methods you've written in class Form1 or in other classes and even trigger other events). So for example with the main window you can use a load event to execute code on startup. You could call other methods at the end of InitializeComponent() but I think it's much more practical to use the events to take advantage of the paradigm.
Just my half nickel but I figured it might help you to get your hands dirty since this ain't your first rodeo.

ddanbe commented: Nice explanation +6
roswell67 commented: directly tackled the problem and explained everything. Loved the post. +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try escaping some " " and putting them in your path, so it treats it as if the filename was in quotes at the prompt:
"java -jar \"/Users/User1/Desktop/Sample Java/Demo.jar\" ";

If not try"java -jar /Users/User1/Desktop/Sample%20Java/Demo.jar ";
but I'm not confident it will work (it will probably just insert the space all over again).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take a look at this thread:http://www.daniweb.com/forums/post246417.html#post246417
Substitute ':' for ',' in the delimiter of the second getline call and you should have what you need (minus fixing it to work with your arrays,etc). You can use an N x 3 array for holding the strings or just do your parsing for ints on the fly. See this for more info on the stringstream >> operator.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you're looking for OCR http://www.simpleocr.com/

Otherwise http://www.google.com/#hl=en&source=hp&q=C%2B%2B+Twain&aq=f&aqi=&oq=&fp=b36c7832dbb01be6

I have not used any of these SDKs so I cannot speak for their quality or content.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Wasn't trying to steal your thunder lol.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try something like this. The true passed to ReadKey() suppresses the output of the character to the screen.

ConsoleKeyInfo a;
            do
            {
                 a= Console.ReadKey(true);
                switch(a.Key)
                {
                    case ConsoleKey.O : Console.WriteLine("You ordered an orange");
                        break;
                    case ConsoleKey.A: Console.WriteLine("You ordered an apple");
                        break;
                       //etc.
                }
            } while(a.Key != ConsoleKey.E);

Since ConsoleKey is an enum it is acceptable input to the switch.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Problem is right in here in main:

if(nspots < 8)
{
	checkToWin(ticTac);
	checkToBlock(ticTac);
	checkWinner(ticTac);
					
}

Both checkToWin and checkToBlock make a move (there was some untangling to figure out which was in fact deducting from nspots). You need to call one or the other but not both. So when N should be 2, it was zero if it took the wrong sequence of events.
My suggestion would be to return a boolean from checkToWin if it "succeeds" and you could use that to a) skip over the call to checkToBlock and b) end your while loop in main() and declare a winner and if not call checkToBlock.
Or give checkWinner a more instrumental role in interrupting your loop if you find a winner and just call that in between checkToWin/checkToBlock. It seems like in the first code you put up you did something similar to that.
Even though it's late in the game (and I've seen the evolution of this program, you have put in a great effort) be thinking about ways to better arrange your functions so that you're not duplicating the work for yourself over and over.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is this

Player one can enter your coordinates for X
2 1
    |    |
  X |  X |  O
____|____|____
    |    |
  X |  X |
____|____|____
    |    |
    |  O |  O
    |    |

N spots 0
DRAW

the condition you are talking about?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

WoW I'm a little embarassed. Thanks.

No prob. It happens to everyone.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 34: It's case sensitive so it needs to be Tests_Weight (or change all the others to match Tests_weight ;) )

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Let's be clear. No one on this site is going to give you the code. If you haven't had C++ in a long time: 1) What a great time to review (and this is a ready problem with which to apply that knowledge) or 2) attempt it in another language with which you are comfortable. Clearly the person assigning this to you believes that you have enough knowledge for the undertaking or that you can use whatever knowledge you do have as a starting point to further your pursuit of C++.
My advice would be to go through some of the "long codes" and see which parts are recognizable to you, cobble something (of your own merit) together and post back.