jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

sorrrrrrrrry!

It's my bad, I was a poor role model when I was trying to be a smartazz.

Don't worry about WaltP, as long as you don't walk on his lawn he won't press charges.

mitrmkar commented: Mmm, are you sure about WaltP?? +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just omit the break in the middle. Switch statements "fall through" until they reach a break;

case 'a':
case 'A': //do stuff here
break;
FriXionX commented: fast help, thanks. +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

NubTruck's approach is correct if you have a Win32API application. I was asking about that because if you were using a different GUI API, the approach would be different.

If you are using the Express Edition of Visual Studio, it is "missing" a resource editor (resources being all the "baggage" your application can carry, icons, bitmaps, etc.). You have to generate your own resource scripts to be fed into the resource compiler that does come with the EE.

Something like http://www.resedit.net/ (not affiliated with this product) gives you back that resource editing. Have a look at that. Regardless, I would take Nubtruck's advice and take a few steps back in that tutorial to see where you first stopped understanding. If you are going to get into this sort of thing, the fundamentals are important.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I used Qt_SDK_Windows_online_v1_1_en . There may be an updated version by now.

A brief runthrough of what I think I selected for install:

Uncheck APIs (counterintuitive, but unless you're doing mobile development, not needed)

In Documentation: Get rid of Qt Mobility and Symbian (if you're just doing PC development)

Miscellaneous: Check Mingw 4.4 (Examples and sources if you need them)
Development tools: Desktop Qt: this is the meat of it, select Qt 4.7.3 (or latest), check the third option down off of that to get the mingw version (no need to take the Visual Studio version if you don't need it, that will save you a ton of disk space)

Uncheck Maemo Toolchain (unless you need these compilers, but they are also for mobile development -- I think it puts all of these on the path, which gums up trying to use the regular compiler)

Try it with that, and babysit the error messages, as if you have a firewall/antivirus all of the command line programs it's running in the background will drive that AV program nuts (and Qt is a reputable product), so you may need to turn it off. If it doesn't take a long time to install, something is wrong, because this is a mammoth.

sDJh commented: thank you! +6
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you look below the signature editing box in the control panel, there's a box

Signature Permissions
Allow Basic BB Code Yes
Allow Color BB Code No
Allow Size BB Code No
<SNIP>
Allow Smilies No
Can Upload Images for Signature No   <----****----
Can Upload Animated GIF for Signature No

This lists all of the permissions for signatures for your account. I believe pretty much everyone's says no for images in signature (admins may be the exception, but I don't recall any having an image for a signature).

jingda commented: Clear as mud;) +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Chars are really integers (see any ASCII table).

char grade = 'A';
grade++;
std::cout<<grade;  //'B'

but this requires you to go up when you are going down in grades, and the skip between D and F would require some extra logic.
What would be even easier, though, is to make it a case statement

switch(grade)
{
    case 'A': grade = 'B';
              break;
   //similar for case 'B'
   //similar for case 'C'
   //cases for 'D' and 'F' are different
   default: //what do we do if it's none of these letters
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Do you have a team? People experienced doing that sort of program? A good database of virus binaries to draw from? A marketing unit to lure customers from the big named products?

peter_budo commented: Nope only big dreamy eyes :) +16
kvprajapati commented: :) +15
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes. All of the controls have an .Enabled property that will allow them to be active or inactive (grayed out). You can also use the .Visible property to take them out of the form temporarily.

Having the logic carried out in a particular order could be done simply by checking to see if there is anything in the TextBox.Text property before allowing the user to change the radiobutton, or as sophisticated as setting a boolean variable during one of the Textbox events, and ultimately checking if it's true in the CheckChanged event of the radio button.

Start playing around with some of the simpler aspects of the UI (how do I gray out or hide one button by pushing another), or if you're beyond that point, take a crack at some of what you describe and post back with specific problems.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There are two ways to fix that. The first would be to go to Project/<myproject>Properties/Configuration Properties/Debugging and specify the working directory as `c:\<pathtoyourDLLs>. The only downside to this is, if you program writes out any files, they will end up cluttering your dll directory.

A more permanent solution is to copy the necessary .dll files into your <myprojfolder>/<myprojfolder>/debug and <myprojfolder>/<myprojfolder>/release directories. Copy over the .dlls associated with the header files that you have included.

Nick Evan commented: Good effort in this thread +16
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster


He had too few Geek genes

Perhaps he should have tried khakis.

jingda commented: lol +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I stumbled across this searching for gift ideas. Thanks!

For me...? You shouldn't have. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's going to be some difficulty right off the bat when you are mixing the unmanaged C++ (the std::vector ) and the managed form (which uses an offbeat dialect of C++ called C++/CLI, so some of the data structures and syntax are different).

The GUI uses something called event-driven programming (which isn't unique to Winforms, most GUIs use it in some way), but essentially, you're not moving through your code linearly, you are doing something in response to someone clicking a checkbox, typing in a textbox, or clicking a button. So, rather than getline, you could, for example, have the user type something in the textbox, and once they select a radiobutton, your code will read the text into variable xyz.

Instead of using a vector (which is theoretically possible, but requires some juggling in most cases), you should use a cli::array (see http://www.functionx.com/cppcli/index.htm) for some decent tutorials) or a .NET List object.

So, that's probably a lot to digest... A lot of the good tutorials for .NET are written for C#, but you can still reference them, as the classes and member methods are all the same, except for the -> and :: notation used in C++ with pointers and namespaces.

Post back as you run into any issues.

ddanbe commented: Nice explanation, but I still hate the word GUI! :) +14
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Go to the designer and select your form. Go over to the properties window and select the lightning bolt (to get the events). Find "Form closing" (not "Form closed") and double click the cell to the right of it. This will put the event handler code into your Form1.h and you can flesh that out as you see fit.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You reset head pointer to null on line 38. Why? It's guaranteed to follow the path of that first if statement each time, and what if there already is a valid head pointer? (hint pass it into your function) That may not be the problem, but it's one of the first places I would look.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 28:

newNodePtr->pengarang = pengarang;

You are only copying the pointer over, not the contents of the string. Use strcpy(newNodePtr->pengarang,pengarang); instead (or better, since you don't know how large your source string is, use strncpy).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No, only high school kids from Singapore... ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Those sorts of low-level direct I/O calls (in the spirit of inp()/outp()) no longer work under Windows (as of NT and later) without a special device driver.

For an alternative look into the Win32 API functions like CreateFile.

See this PDF as the author seems to go through those functions step by step.

Nick Evan commented: Yup. +16
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Not to interject now that this is solved, but give chapter 35 of the C++ FAQ (particularly question 12 a read. It's one of the clearer explanations I've run across.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Have a look at this (there's a nicer version for VS 2010, it's probably virtually the same set of keybindings).

Mr. K commented: THanks Jonsca +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Better you must read it properly....

Better you reread the thread because you don't seem to understand the clear explanation that Narue was giving about undefined behavior.

Killer.bee commented: Ohh i think you need to rereas -1
Nick Evan commented: counter. +16
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

By virtue of C# being the more prevalent .NET language, most of the tutorials don't use the C++/CLI syntax. You're better off looking at a C# site like http://www.c-sharpcorner.com/Articles/ArticleListing.aspx?SectionID=1&SubSectionID=167 and trying to translate the syntax (sticking in :: and -> when needed).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Delete line 5 of Form1.cpp and move lines 20-24 out of Form1.cpp and into a new file xxx.cpp. It shouldn't make that much of a difference, but it's good to keep Form1.cpp clean.

I had told you that in xxx.h, you need to qualify String^ as System::String^ as the compiler has no notion of it otherwise.

System::String ^ParseBBCode(System::String ^OriginalText)[B];[/B]

(you didn't have the semicolon after the declaration, but I'm not sure if that was a typo.

emanfman commented: you helped very much. thank you! +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm assuming that you're working in C++/CLI since you are doing WinForms. Check out the BackgroundWorker, as I believe that's the most straightforward way of getting a separate thread (and I believe it was designed for exactly this purpose, i.e. for separating the GUI and the meat of the code).

Just make sure you're not running life support systems or nuclear missile silos with these motors. If that's the case, you'd probably want something embedded.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The money's not the best

Everybody always says that, but they forget that there are just so many perqs beyond the salary (not to mention all the book deals and speaking engagements afterwards are probably enough to keep them afloat). I'll bet the president doesn't pay for internet and cable ;)

FWIW, I think William Henry Harrison was the best president ever.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i can just include a welcome speech at the end of my post.

Put it in your signature. "If you're new, welcome, if you're returning, welcome back, and if you're here all the time, you're WaltP" :)

jingda commented: Nice one +0
WaltP commented: Ouch, my side hurts :-P +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Make a list for yourself of precisely what is confusing about those topics, for example

Typecasting:  Is it necessary to cast my variable when I am doing XYZ
Twos compliment:  How do I handle negative numbers

etc.
Now you have a list of things you can search other sites for, like you can Google "C++ typecasting XYZ" or "2's compliment negative numbers". I know people on this site would be more than happy to help you with specific questions about specific areas, but you've got to figure out what those are.

Fbody commented: Very true, And good advice.. +5
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sure, someone will be glad to help, but please make some attempt at those two functions. No one is going to write it for you. I know you said you "messed up," but that's what we need to see to get you going in the right direction.

Start with the input function, that shouldn't be anything you haven't seen before, step through the array with a loop and prompt the user to input all of the fields.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I get quite a few compilation errors with your code about your use of the methods in algorithm. As an aside, check out http://www.daniweb.com/software-development/cpp/threads/262894 for Narue's solution to the problem with using toupper in this context.

Edit: you didn't include <limits> for the cin.ignore call

vector<string> words;
const string THE_WORD = words[0];

What is words[0] equal to when you are trying to assign it? There is nothing in words, it's only been declared. Even if it were valid, there's really no need to have these variables global anyway, I'm not sure why you did that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Grab #7 (it's free and legal) from http://www.qtrac.eu/marksummerfield.html. #6 is the current edition, but I don't know how much that is.

The book takes you through making a rudimentary spreadsheet within the first few chapters.

It also goes on to talk about the other aspects of the library like the abstract data types, sockets class, database connectivity, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See this thread on Stack. It's using C#, but you should be able to translate the syntax readily.

Like I had said in the other thread, it takes a little wizardry to update the GUI from another thread (which is basically what the backgroundworker is).

I have never actually implemented this (I've used backgroundworker for different tasks), and I definitely don't know how to handle it with raw API calls.

Pay close attention to the answer with the green check (and the associated comments), as I think that gives more or less what you need.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Do your API call in a backgroundworker (http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx). It's the "easiest" way to do threading in .NET. The only thing is, you have to pass back your information to the GUI in a specific way (which I cannot remember right now).

triumphost commented: Thanks for all your help :) +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did you run into this one http://www.scribd.com/doc/43968817/Write-a-Program-for-Imlementing-Perceptron-Learning-Algorithm ? Which part of the cprog part is giving you trouble? The Perceptron is a pretty bare bones architecture, and there are lots of situations where it just plain doesn't converge.

What type of project are you adopting it into? (if it's not top secret, lol)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

calling a native C++ DLL from C# is possible

See this recent thread http://www.daniweb.com/software-development/cpp/threads/355990 for the caveats of that statement.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

However with all the libraries available for C++, wont C++ still stay a bit head when developing native programs?

Yes, it will stay far ahead. C++/CLI was never meant to home in on the C++ market, but was just meant to be a tool that is right for some jobs.

I'm assuming then using .NET wont allow you to use the a program developed in C++\CLI to compile and run on say a Mac then, compared to a general c++ program that can be compiled and run on a mac ?

Not yet, but maybe not ever, I don't know. I know the mono project (http://www.mono-project.com/Main_Page) is trying to get C# and .NET to work across Windows/Mac/*nix, etc., but I don't know if they have any plans to port C++/CLI. A library like Qt (which has GUI elements, but also has other components for things like sockets and database access), is something that would serve you well in developing cross platform apps.

Sorry if my questions seem a bit naive just trying to cover all my bases

No worries, sometimes it's hard to find information out on the net about it. I think some people want to put it out to pasture. I just find it to be an interesting dialect.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

C++/CLI is the dialect of C++ which you use under the CLR. Languages that use the CLI have their code converted to MSIL (which is like assembly language, but not quite the same). The MSIL code gets run on a virtual machine, and a just in time (JIT) compiler turns it into bytecode. (I may have glossed over some points, so Wikipedia has great info on all of this for further reading).

When MS created managed C++ (the precursor to C++/CLI) they intended it as a go between in the relationship of native C++ and C#. That is its biggest advantage, IMO. You can write code in C++/CLI, and call it directly from C# (or VB, etc.), whereas calling a native C++ DLL from C# is possible, but requires a more elaborate procedure known as a platform invoke (P/Invoke). Of course the C++/CLI approach isn't perfect, and still requires a lot of translating pointers when there's any native code present. One upside is the ability to write WinForms programs in .NET, rather than operating with Win32API directly.

The downsides are numerous. This is not standard C++ by any stretch of the imagination. Some of the syntax is different, managed pointers are known as handles, which behave largely the same, but require some getting used to (as the memory is now managed by a garbage collector since you're in .NET). It's a bit esoteric (that's kind of what I like about it, actually), so it's not necessarily something that's …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where do you modify c2 in the loop? Also, why is it a double?

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

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

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

To start down this road, check out http://www.winprog.org/tutorial/ (it's not going to answer your questions right away, but once you get going you'll understand what's going on).

P.S. This thread is ancient. Sometimes better to let them rest and start a new one.

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

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

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

The whole idea of writing the strings into the array was that you could scan through the set of strings for your substring after you had read all of the strings in. Do only the scanning within the loop.

Move 17 outside of the loop (it can even go before the while loop if you want).

Also move line 18 out, but change it to step through your string array (hint: a loop will be necessary) and print out the strings that match.

I've nudged you along here, but you need to be able to do some of your own debugging. If the code isn't doing what you want it to, put some statements in there to output your variables at intermediate points to see what's going on -- or use a debugger.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You'll have to shift your while loop around to encompass the information that was in your for loop

while(not at the end of the file, read in a char)
{
   if that char is not '\n'
       add it to the string
   else
       //line is done
       check to see if the substring is in the string
       if(so)
           print it out
       else
           clear the string and continue on
}
Saith commented: Nice pseudocode +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

while(counter < months) I meant, sorry.
counter = 0, counter < months = true, loop continues
counter = 1, counter < months = true, loop continues
...
counter = months, counter < months = false, loop stops.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You've got months and counter flipped around. Count up until you reach months, not the other way around.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Remove the =0.03 from the declaration (line 11).

balance is a parameter of enterAccountData(), so it goes out of scope once that method ends. Use accountBal in computeInterest() instead.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

On line 61 do a strcpy instead to move it into the buffer. Right now you're concatenating a good string onto junk. Then concat onto the newly copied string.

It looks like strcat_s takes a size parameter like strcpy_s does, so did you use it with 3 arguments?

Also, since you're going to run into it anyway, look at the order in which you are adding the strings in 61 and 63. So, you'll want to strcpy the first one and strcat the second one.

L3gacy commented: thanks +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, I'm on Chrome(9.0.597.107), too. I should have mentioned that. Hmm, but Walt P was able to vote and rep on your post. What's your browser poison, WP?

Edit: It worked for me in this forum.

happygeek commented: rep working now +0