jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i need exact instructions on what to do

You're asking a lot from us.

You need to do some background reading on Wikipedia (see for example: http://en.wikipedia.org/wiki/Widget_toolkit and http://en.wikipedia.org/wiki/Win32 for some of the background on that other tutorial I linked for you) and decide which toolkit you want to use.

Win32 tends to be the more powerful option, but takes pages of code to get a simple window functioning. The other options cover some of it up for you, but it still takes a lot more than you're probably thinking it will.

I'm not trying to discourage you in any way, even though it might seem like it, but just the opposite. I just want you to know what you are up against, and I want you to be able to know what the options are before you choose one. Are you just getting started with C++ in general?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Glad you got that part of it working!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Which windowing library are you going to use?

I think Dev has the Win32 API included (good tutorial here http://www.winprog.org/tutorial/). You might be better off starting with another GUI option like Qt (which will come packaged with a newer version of g++ than you have with DevC++).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Adding this to local variable x

Right, because the variable at the local scope with the same name as the global one essentially "blocks" the global.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Nah, I'm kicking over tables and smashing bottles over this thread. ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, that's correct. Can you explain to yourself (and future generations) why?

frogboy77 commented: :) +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Ok, OP. Now, what was your rationale for your answer?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

[Opinion]
Yes, as it stands it sounds like the OP wants a quick answer. If you have a means to check, check it. Then try to figure out why the answer is right or wrong. Then post.
[/Opinion]

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's a fantastic way to check the output of any source code ;)

Please explain your rationale for your answers, they are not correct.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I still get errors with that, even when I try to compile on the command line.

Invoking g++

FriendClass.cpp: In member function 'void FriendClass::changeMyVariable(MyClass*
)':
FriendClass.cpp:15:8: error: invalid use of incomplete type 'struct MyClass'
FriendClass.h:6:7: error: forward declaration of 'struct MyClass'

Within C::B

obj\Debug\main.o||In function `main':|
|9| undefined reference to `FriendClass::FriendClass()'|
|11|undefined reference to `FriendClass::changeMyVariable(MyClass|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 3 seconds) ===|
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I may have to recuse myself from this one and learn from whomever gets it right, because I've tried darn near everything. This is one of those "circular" situations where they both depend on each other (since you have the variable in FriendClass being passed as a reference to MyClass, and of course the friend function going in the other direction.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

@Jonsca : I'm compiling it using IDE - Code::Blocks. But what difference it makes

If you were doing it on the command line the order of the files can matter. Let me pull your files into a project and see what happens.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How are you compiling these? As a project in an IDE or on the command line?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to "forward declare" FriendClass at the top of MyClass.h. On line 6, put class FriendClass; . This tells the compiler that such a thing exists so it doesn't complain when it runs into the symbol in the MyClass declaration.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

BTW, you're missing an eq2 on line 78.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, it looks good, but as I suspected you're missing a head pointer. It would be just like NIL except the "tail" of it would point to the first Cons. You can't start at NIL because NIL doesn't have a pointer to the prior node.

|h |->|  |->|  |->|N |
->can only proceed ->

(this is why doubly linked lists were invented, so you could traverse from either end).

That's probably more abstract that you bargained for, but give it a try and see how far you get.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you don't have a limitation, you should post the code out in the forum so that everyone can learn from it. It's against the site's policies to help through PM, anyway. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can I use to "reimp" and "dlltool" to convert the lib file into a .dll and then use it through MINGW?

I've never done that, sorry. I'm sure there's someone around that has. A lot of the libs I use, I end up using with Visual C++ because I've found it to be the path of least resistance. I'll post back if I run into anything, though.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What are eq1 and eq2 equal to before your loops start?

A head pointer should have been a fundamental part of your design, what pointing to the first node of your list now? Set eq2 to whatever the beginning of your list is.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Change the inner loop to for(eq_2 = head; eq_2!=nil; eq_2 = eq_2->tail) (substitute whatever your head pointer actually is), that way the second loop gets reset to the beginning of the second list. I think that's what you're trying to do...please clarify if it's not.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I looked around and ended up with the same information that you did, but read this http://cboard.cprogramming.com/c-programming/55152-trouble-strndup-function.html (especially the post from Salem) about the compiler switch -ansi being incompatible with the non-standard functions (you don't use any switches in your example above, but I didn't know if the server had a different setup)).

If you go into your schools include directory, you can open their string.h and make sure the declaration is actually in there (I don't remember the directory structure on *nix, I think it's something like /usr/local/include, but don't quote me on that).

Failing all that, as the thread also recommends, you could roll your own out of standard library functions.

P.S. It's not very polite to bump your thread

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, you're totally correct as usual, Vernon. Good example. For whatever reason I was thinking he was redeclaring the ifstream object rather than just opening and closing the same one. Sorry.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't get any kind of error

2336
Pencils4.5510
1234
Stockings12.3923
0
406.048
0
-406.048Press any key to continue . . .

Just some issues with not having newlines at certain places.

Your counter is going unused in this version, which is probably okay. You can probably check to see if infile is null (if so, you've run out of file) rather than counting. Check into what Vernon was saying, too. My thought is that by reopening the file you're resetting the stream, but test that out (using an infile.clear() to reset it).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay, thank you. So what you need to do is select the "1" rather than the "Matt Whitehead" because there's not way for the compiler to get an array index out of "Matt Whitehead." It seems like the other routine you posted is doing that very task, though.

When you try to set:

OpenStaff->txtName->Text=FirstName[int::Parse(_selectedName)];

int::Parse is trying to extract a numerical value from "Matt Whitehead" and failing.
Even if it could parse the string, you'd be trying to take the "Matt Whitehead" element of FirstName, which does not work in C++ (it might work in Javascript or PHP).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No, there's a setting under both C::B and VS (but if you were compiling from the command line you could add the switches)

In VS2010: ProjectMenu/<projname>Properties/Configuration Properties/CC++/WarningLevel change to /Wall (I'm not sure what the difference between W4 and Wall is) -- I think this changes it for the project, not sure how to do it globally.

In C::B (v. 6931) Settings/CompilerDebugger/GlobalCompilerSettings/CompilerSettingsTab/ 4th option down

iamcreasy commented: Thanks :) +2
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It matters what's in it:

"23" -> okay, easy to get 23 out of this using parse
"23restofstring" -> can't get out what we need -> throws exception
"restofstring23" -> same deal, can't get what we need ->throws exception

If you string is either of the last two cases, parse is not going to work on it.

Until we confirm what is in the string, we can't go any further. Once we know, we can truncate it to get the number out of it and parse that. I refuse to play games, either you figure out how to get access to that value or I will not be able to help. Period.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use -Wall (for gcc) or /W4 (for VC++) as a compiler switch to turn on the highest warning level. With lower warning levels set, the compiler suppresses warnings it considers "less serious." You should almost always compile with the highest setting.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Then make an additional text box on your form (temporarily) to display that value. I'm really absolutely certain that's where the problem lies, but if you can't tell me what _selectedName is before those int::Parse calls, I'm not going to be able to help you. I'm not sure why you are fighting me on this, these debugging steps are a critical part of the process.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, because if _selectedEmployeeID is a string with just a number, int::parse is not going to have any problem with it.

What do you mean "it doesn't work"? It wasn't meant to fix the problem, it's meant to indicate what is in that string at the time. It's important. It can't parse the string, you've got to figure out what is in there that is throwing int::parse off and fix it. Me logging into your system is not going to change that, plus the policy of the forum is "keep it on the site."

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'd prefer not to do that, let's keep it on the site. On line 9 of the last time you posted code, put in System::Diagnostics::Debug::WriteLine("****** "+_selectedName+" *******"); Run your program, now in the bottom window of the IDE (marked output) tell me what's in between the stars.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Right, no I understand what you are doing, but the way you are going about it is incorrect. If _selectedName has any text in it, it messes up the int::Parse. That's why I'm asking what is in _selectedName at line 8? If it's "23 BobJones" it's not going to work, you'll have to take the substring with just "23" in it for the number to be parsed properly. If the number is not parsed properly, all of your indexes in lines 14,17,etc. are invalid, unfortunately.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See http://en.wikipedia.org/wiki/Stdlib.h#NULL as to some of the variants and rationale.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

As Jonsca said,

There should be a button to insert that phrase in the advanced editor.

Also, @OP, main is always int, never void, according to the standard. Even if your compiler takes it, it shouldn't.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

after deleteing I want to show the array contents........

That doesn't make one bit of sense. Also, why are you trying to delete the array multiple times, delete [] array; takes care of it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hover over _selectedName, not firstName, there's something in the string that can't be converted to an integer.

All else fails, put in a line System::Diagnostics::Debug.WriteLine(_selectedName+" STRING"); and read what it says in the output window of the IDE.

Also, just as a side note, you can prevent this by using int::TryParse instead, it will return a value of false instead of throwing an exception.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I've declared it as a string,

" String^ _selectedName = lstName->Items[myIndex]->ToString(); "

But what is the value of it? Mouse over it during the crash and it should tell you.

I don't know what was up with that other poster...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

what's the value of _selectedName at that point?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Resetting your counter to 10 at the bottom of the counter will cause it to run forever if you can't find the item, I'm not sure what you're trying to do there.

I would copy/paste all of your code into a separate file and strip out all of the output code in that loop until you get the input working the way you want it to, then add it back in.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I believe he's referring to the video on the page he linked to, not the link itself.

Palm2Face() sorry totally missed what he meant!

To answer the question:[youtube]HEheh1BH34Q[/youtube] is what he used (for reference:hitting reply to on his post quotes his message directly so you can see all of his tags, then just hit the back button to escape).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is the desired behavior on #3? If you type the link in plain text, it will be parsed into the abbreviated form like that automatically.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

#include <cstdio> which is the C++ version of the stdio.h header.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would read the data in as a std::string using getline and go through character by character (or using datain.get() to read the file in character by character) rather than dealing with doubles (especially if there are +/- and other characters thrown into the mix). You can use the functions in <cctype> to figure out if the characters are numbers, or simply use something like

char c = 'd';
if((c >= 'a' && c <='z') || (c >='A' && c <='Z')|| etc.)
    //etc.
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't have any insights into your problem, but I'm curious about something. Doesn't the compiler complain on line 14 that lwFile isn't a const char * ? Normally the fstream objects take a C-string (so you'd need lwFile.c_str() in that spot instead).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Look for libraries that support CMake, as that makes life much easier when setting things up to compile. The libraries will specify that they are compatible with it, or look for .cmake files in the main directory.

Otherwise, I don't know any specific libraries, but it looks like there's a wireless SDK for XP and Vista. Those are probably best used with Visual Studio, but I don't know that for sure.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

t=0 should be t==0 (the first assigns 0 to t, the second checks for equality), etc., but in this case since t is a double, it is tough to compare with 0 or 1, etc, due to the inexact representation of doubles. What does your data file look like?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just use the other version of getline:

getline(*streamReader,headerInfo);

string is simply a char array correct?

I'm not an expert on this sort of thing, but I think the std::string class code could be implementation dependent, so I don't know to what extent you can rely on it being a simple wrapper for a C-string. The above solution gets rid of the issue altogether.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I was wondering if anyone could help me out on this library

Which library are you trying to use for the Bluetooth?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure I'm going to be able to help. Print out (I'm not sure how you do that in mysql) the columns of the row and the value of b to make sure you're not overstepping something when you're seeking. It looks like if you're reaching the point that's causing the error, that the DB is returning valid rows, so that's not a concern.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is there a line at which that is occurring?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I've remained reticent on this issue because I have dealt with the original poster in the past. He knows I that became the most irate when he banged out a solution to a problem and pasted it into the box, usually leaving no explanation. He underestimates the fact that any one of us could have done the same thing, but those who have taken the route of trying to explain something are punished.

If you want to help someone, you have to try to solve their real problem.

I agree. I would say for the majority, most of these students seeking help have been given snippets and samples already in their classes, and they are not able to extrapolate what they know. If someone really and truly needs a complete concrete example, I might illustrate a portion of it, but I leave the incorporation of that into their example/homework up to them.

But that's hardly our fault.

I understand what you are trying to say, but at the same time, if you give a child a book of matches to play with, you can't say "I didn't know he would burn down the church." Obviously, the posters are not children, but if people are not given a chance to plagiarize, they can't.

It's basically a slap on the face of someone helping out to post the solution on the 2nd/3rd page of an ongoing discussion.

I can think of maybe one time that I was explaining something,someone else …