jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What type of image? You're going to need some kind of a library, regardless, as there's nothing in standard C++ that will open an image.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See http://www.cplusplus.com/reference/clibrary/ctime/ (each of the functions has an example to go with it when you click on it)

Otherwise google for ctime or time.h (which is the C version of the header, but it's the same functions).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What are the specific issues that you are having with it? "It has many mistakes" doesn't give anyone much to go on.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I ran your code as is and entered 3 students worth of data in step 1, and then went to step 3 and the data displayed as I had entered them. What does your output look like (you can paste it right in with code tags).

I don't think this is the root of it, but you might want to consider converting your scanf statements for the strings into fgets statements, that way your user can't input something that will overrun the char array.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is the general area of the internship (they could potentially ask you questions about any topic), but to direct you to something specific, it might be helpful to know. Accelerated C++ (Koenig, Moo) is a good one that will start out with some of the principles from the latter half of C++PP, and will start right into learning to use STL containers, etc. as an integral part of the text and examples. There are some specific books on templates that are supposed to be good (I haven't read them), and I'm sure people will have some other books for more specific areas.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Most, if not all, of the solutions that you will find will be non-standard and depend on the operating system. Which platform are you using? To get something that can be used cross-platform, try looking into PDCurses (pdcurses.sourceforge.net).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

why not use cin object as a test condition? That way it can get type mismatch and it won't write data to that type and we can easily get rid of bad input and ask user to reenter with proper data. Would this be a bad approach?

That will work, too. OP, you'll need to use either the .fail() or the .good() method of the input stream for that (see http://www.cplusplus.com/reference/iostream/ios/good/ etc)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use getline to read the lines from the input file into a temporary string:
Read: "My name is Suman" as a std::string
Does this contain "somnath"? No, so write directly to the output file

Read:"My son's name is somnath." as a std::string
Does this contain "somnath"? Yes it does. Replace somnath with "shridhar" (perhaps using the replace method of the string).
Once this change is made, write the temporary string out to the file.

Obviously this will need to be in a loop to get all of the strings in the input file.

Give it a try based on that, and post back with the code (and please use code tags: type in [code] //code goes here [/code])

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It might help to know what you are trying to accomplish, unless this is just an exercise in theory.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

scanf has a return value which will tell you how many items were successfully converted (it returns EOF if no input is given). Use that in the condition of a small loop around lines 9-11.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Post your effort thusfar. Otherwise start with, can you read a file? Can you get input from the user? If you can read from a file, read the two values at the top of it and use those for your subsequent read. Come to us with specific questions.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Explain to me how your code solved the problem as it was given to you. It does not ask about divisibility by 11 directly, it asks you to use that method they gave you.

Also, please use code tags [code] //code goes here [/code] when posting code.

Hint: you need some way to get the digits of the number. Meta-hint: I gave you a hint on how to do that. With an integer it takes a lot more effort to get the digits.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check out the header <cctype>, as it has isalpha(), isdigit(), etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

LOL okay. I'll give it a test if I have a chance.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Reading in the integer as a string would probably be the easiest. Take a crack at it and post your attempt, otherwise we will not be able to help you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Declare a picture box, set it's coordinates and background image (and the background image layout). Once that's all done, use the .Add() method of the tab control to place it on the form (I think the default is visible, so you don't have to set that before adding it). See if that works, otherwise I'll put together an example to refresh my memory.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Care to share with us where they come from?

They are Turbo C headers (and/or non-standard ones). It was considered a nice compiler back in 1992.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take a look at this: http://www.cs.tut.fi/~jkorpela/forms/cgic.html Common Gateway Interface is the name for this sort of thing (Colby even calls it that on the websiste). That link goes into some of the technical aspects of it, but it seems if you can find hosting that will run CGI scripts then you should be okay. I don't know if it's correct, but it looks like in that link they compiled the C program to an .exe and simply renamed it .cgi.

Under the software/development tools table further down on that server company page it lists "Full Cgi-Bin Support." You may want to check with them, but that's probably what you're looking for.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It wouldn't change much of your code at all to put in the do/while loop

do {
/*all of your code from 8 to 22 */
} while(choice == 'y' || choice == 'Y');

then eliminate 23-25.

Calling main like you did is technically recursion. It's not forbidden, but be aware that each time main() would be called from itself, the "state" of each call to main would be conserved on the stack as another instance of it was called. Those representations (address/instruction to return to, and I think local variables, but I'm not sure) could pile up ad infinitum or potentially until it crashed your program.

Looking something like (but don't quote me on the specifics -- take a look at http://en.wikipedia.org/wiki/Call_stack for a good overall explanation):

[n-th call to main()]
   .... 
[3rd call to main()]
[2nd call to main()]
[1st call to main()]

I read up a bit on it, and it seems how you had it set up was a "tail" recursion, which the compiler can optimize away if possible. Doubtless someone knows whether or not this type of thing is allowable under the different standards (C89. C99, etc.), but I wasn't able to find any clear cut statement on that. I do know it's non-standard in C++, but that has no bearing on C per se.

The bottom line is that a simple do/while avoids all of this potential headache. I am not sure about your book's statement about …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can I just add that what I'd like to achieve is a night of passion with Avril Lavigne.

What's stopping me is the wife...

Why choose? ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Also, you're now using the C function

I think this belongs in C, I flagged it for a mod.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Have you covered scanf in class? (arguably you should use a fgets/sscanf pair, but I don't know if you've learned those yet)

Read in an integer value using scanf(call it n_user or something) and replace that hard coded 5 that you have there with n_user.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure if this configuration is dictated by your assignment, but, in my opinion, I think your circle class should have a point member ("composition") instead of deriving from the point class. What you are seeking is more of "has-a" relationship ("a circle has a point(center)") instead of an "is-a" relationship ("a circle is a point"-doesn't really fit). I realize the is-a/has-a suffers from some limitations, so that's why I'm presenting it as an opinion.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Oh, it's just a string to temporarily hold the string at the front of the queue, since he's putting the elements into a new queue he created (which was not a copy, but just an empty queue) -- once the first element is popped off of the original queue, it is lost.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Based on your original post and griswolf's explanation you should know how to show all of the members. Give it a try first, knowing that copyq is an exact copy of your original queue.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just like when you declare an object and copy in another.

Queue<string> copyq(myqueue);

or call it Bob or something.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please use code tags [code] /*code goes here*/ [/code]

You shouldn't call main() like that, but the real problem is the semicolon at the end of your if statement if (choice=='y' etc) . If the if statement is true, the then "statement" is ; and then the program continues with the next line.

Read a little ahead in your book to the do/while statement section and replace your call to main() with that.

One final thing, when dividing 2 integers you're going to lose the decimal information. Also, try putting in a fraction like 5/7 and see what happens.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

(Copy queue to another name, show next, pop.)

That's essentially what I was saying to do. I'm unsure of what your hesitation is.
(I forgot that pop() doesn't return the value of the popped object, so showing then popping is the way to go, sorry)

id also like to apologize if i seem a little curt.

No worries.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's the catch-22, you can't view all the members and keep them in their place in the queue (as griswolf pointed out). That's the crux of the datastructure. I like griswolf's idea, or along those same lines, pop them out and push them right back onto the queue until the first element is first in line again.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you pop all of the elements off of your existing queue to view them, then there will be an empty queue. I was presuming you wanted to be able to view the copy of it while leaving the original intact.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't know if this was the intention, but perhaps make a copy of the queue and pop all of the elements off? (no warranty granted on this one lol)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In 42 through 47, you never subtract off the part of the number that was just added to the string, so number is still = 467, which is greater than 9 so your last if statement gets skipped over.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In your simple program, is it displaying the "Enter a number" prompt?

Putting an "endl" after a cout statement puts in a newline and also flushes the output buffer. I believe you can simply put a "flush" if you don't want the newline.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you search around in this forum, you should find plenty of information on connecting to SQL Server.

http://www.java2s.com/Code/CSharp/GUI-Windows-Form/Radiobuttoncheckchangedevent.htm is a good example (the elements are added programmatically, but the ideas are the same. Google around and see which tutorials match your learning style.

This solution might be a bit kludgey, but you could label the radiobuttons 1-5 and read the label of the element that's selected.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

thanks...how would u generate a report at the end, for a particular instructor and how would you save each response into the database...there are like 30 qs...should i create a group box for each of the 30 qs.

You can generate a report with either a total of all of the points (assume 5 for strongly agree on down to 1 for strongly disagree), or just a tally of each of strongly agree, agree, etc.

Are you talking about a SQL Server database or are you just talking about a text file that you can write out and read in again if necessary?

I think one group box for each set of 5 would be appropriate. I think there's a way to treat the radiobuttons in the groupbox so that only one can be selected at a time, but my memory is fuzzy on how to do it.

I think that your idea is perfectly feasible, so get some ideas down on paper/place some controls in the IDE and try some of the coding. You can always post your attempts and what you need help with.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Which part was unclear?

Lines 64-68 don't do anything, it's technically a valid statement when you write "0;", but why would you?

The braces that you have in the code don't match up, so an opening brace "{" has to match a closing brace "}" somewhere.

There's no ambiguity in the last part. It's not a mean sentiment, I'm just being truthful with you, you are missing fundamental concepts that need to be learned or re-learned.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How to craete graphical user interface on windows platform without Qt?

There are any number of other options: Win32 API, Winforms (C++/CLI), wxWidgets, FLTK, GTK.

MCF is not anymore included in Visual C++

MFC is not included with the express edition, but it does come with the full version of Visual Studio.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sounds quite feasible to me. What's the problem? It'd be a bunch of radiobuttons and groupboxes, presumably.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just rewrite the skeleton and copy and paste the old information in

if( )
{
    if()
    {

    } //close inner if

    else
    {

    } //close inner else
} //close outer if

else
{



} //close outer else

Make little notes like that to yourself to verify you're closing them at the right place (just for now). The issue with yours is that you don't close down the inner if statements at the right spot.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Honestly, if others will forgive my heresy, in my opinion WinForms are a lot easier under C#. The benefit with using .NET is you can design your interface in C# and reference C++/CLI code and/or native C++ dlls right from your C# code.

Of course, there are lots of other options, you could use Win32 API directly, or something like Qt or wxWidgets. There's a Qt book out there (see http://www.qtrac.eu/marksummerfield.html for a free and legal copy, called C++ GUI Programming with Qt 4 (First Edition) that's available in PDF form, and the second edition is partially available on that page also) that takes the reader through the process of making a simple spreadsheet. That would give you a framework upon which to base your word processor.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

MSDN is very helpful in searching for class names, method names, and member variables. Try out some simple applications first and certainly post any difficulties you are having (with code wherever possible).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take in your number as a string using fgets and check the string for good characters (characters from '0' to '9').

fflush(stdin);

Take a look at the links in http://www.daniweb.com/code/snippet217396.html to see why that is not a good idea.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Firstly, please use code tags [code] //code goes here [/code]

Your function definitions (down below) don't match your prototypes at all.

Also, take a look at your assignment and figure out what your functions are supposed to do (you have an uninitialized variable which you divide by a constant, etc., it's not right). No one will do this for you, but we can't even begin to help you if we don't have any idea what your objective is.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Perhaps someone in the Windows forum would be better equipped to answer this (as it seems to be less and less of a C++ problem). If you think that's the case, hit the Flag Bad Post under your name and let a moderator know that's what you want to do.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's the beauty of it, it will be your word processor, so it can have any functionality that you want. Start off with just a rich text box, which will give you a lot of the editing functions built right in (or start with a plain textbox and add in the functionality). Make an edit menu so you can cut and paste. Learn to read and write files so you can save the user's work (see System::IO::StreamReader and StreamWriter for that purpose, at least initially).

Spell check the way Microsoft does it will be a bit trickier. You'll have to parse what the user is typing and compare it against a dictionary. A spell checker that does it all in one pass is probably easier to implement.

Do you have enough experience with WinForms already that you know how to use the IDE to generate event handlers and such? If not, go back to a basic tutorial before you take on a large project like this. See, for example, functionx.com/vcnet/index.htm

kvprajapati commented: :) Indeed. +12
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Initializing it like that only works when you're declaring it

char addr[] = "Cane Gardens";

but not after.

For your case, you can copy a string in directly:

strcpy(account[0].address,"Cane Gardens");

Just remember there is a null character ('\0') at the end of "Cane Gardens," so make sure your address array is big enough to hold whatever you copy to it plus the null.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You have:

An array of structs, account that is type electro.
account[0] is the first of the structs
account[0].address is the character array (a C-string if it's null terminated)
account[0].address[50] would be the last [B]character[/B] of an array that's 51 members long, which is one more than your array has

You can't just redeclare address like that, it's already declared in the struct. Rather than try to copy it in character by character like that (which might work under some circumstances, I can't remember), you should just strcpy your initialization string into it

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please use the code tags. There is still time to edit your post. Click on Edit underneath your name and put the code in [code] //code here [/code]. Also, what is your question?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Look at what you are trying to do, you are trying to place a bunch of characters into a spot that is one past the end of the address array (it goes from indexes 0 to 49)

Check out strcpy to get the string into address, as someone had suggested above.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What do you propose that lines 64-68 are doing?

You've got a mismatch with your braces, too.

I think you're best off doing some reading or tutorials first, plan out your code with pencil and paper, and then do the coding.