[C++] Need help with Dynamic Arrays/Pointers/Structures via /r/learnprogramming


[C++] Need help with Dynamic Arrays/Pointers/Structures

I'm working on an assignment for class and I'm stuck on something I haven't been able to figure out. The program is lengthy so here are the snippets of my program that relate to my question.

This is a global structure:

 struct menuItemType { string menuItem; double menuPrice; int Count = 0; }; menuItemType *pMenu; 

This is the function call from the main function:

 int main() { menuItemType menuList[8]; getData(menuList); 

This is the function that is called from main function:

 void getData(menuItemType *pMenu) { menuItemType *menuList; int NumOfItems; cout << "How many items are on the menu? "; cin >> NumOfItems; menuList = new menuItemType[NumOfItems]; for (int i = 0; i < NumOfItems; i++) { cout << "What is item #" << i + 1 << "?" << endl; **cin >> (*pMenu).menuItem;** **menuList[i] = menuItem;** pMenu++; } } 

The part in bold is where I'm having my issue. What I want to do is read in the item name and put it in the structure, then put the item name inside the dynamic array. I believe my cin statement is correct but I know the next line is definitely wrong and I'm unsure how to fix it. Any tips?

Edit: After I save all the menu items into the dynamic array, I need to return the pointer that is pointing to the first element. I know this means I will need to change the function from a void function but how do I get pMenu to be pointing at the first element after it's been incremented by the for loop? Would I just type pMenu = 0?

Submitted March 31, 2016 at 06:39PM by FeelWhatIFeel
via reddit http://ift.tt/1RADtCh

How can I make a loop for creating a multiple choice question in java? via /r/learnprogramming


How can I make a loop for creating a multiple choice question in java?

public class Item { String question; String [] possibleAnswers; char correctAnswer;

public Item(String q, String [] pa, char ca){ question = q; possibleAnswers = pa; correctAnswer = ca; } public String getQuestion(){ return question; }

public String [] getPossibleAnswers(){ return possibleAnswers; }

public char getCorrectAnswer(){ return correctAnswer; }

public String toString(){ for(int i = 0; i<possibleAnswers.length; i++){

That's my code so far, but I'm stuck on creating a loop that will display all the possible answers. Help please 😦

Submitted March 31, 2016 at 06:47PM by spazzifier
via reddit http://ift.tt/22T76Jv

Sybase date format question via /r/learnprogramming


Sybase date format question

I am trying to take a record with an incorrect date and subtract a year. I have this:

update dbo.startdate set date_start = (dateadd(year, -1, date_start), 101)

That subtracts the year, but it messes with the format. Leaving out the 101 also results in the incorrect format.

I found this link: http://ift.tt/1RsIsrS

But I can't find the one I'm looking for.

I want this format – 03/05/2009 01:03.05.123456

Thanks in advance.

Submitted March 31, 2016 at 06:51PM by cboath
via reddit http://ift.tt/1RADqX3

Where can I find videos of developers working on web or mobile applications from start to finish? via /r/learnprogramming


Where can I find videos of developers working on web or mobile applications from start to finish?

And I don't mean tutorial videos, I'm just looking to get a feel of how experienced developers approach a new project, whether it's their personal project or some dummy project.

Submitted March 31, 2016 at 06:52PM by SaikyoHero
via reddit http://ift.tt/22T76tc

Is it safe to use early/late binding of arraylist from .net in VBA for a program that gets run on other machines? via /r/learnprogramming


Is it safe to use early/late binding of arraylist from .net in VBA for a program that gets run on other machines?

Dim myList As Object Set myList = CreateObject("System.Collections.ArrayList") 

Lets say I write this in my VBA program.

Then I distribute my program to many users with different machines.
Will they have any problems running the code?

If I do early-binding to make programming easier with intelisense is there a chance that will break the code on other machines as well?

Submitted March 31, 2016 at 07:00PM by commentsOnPornX
via reddit http://ift.tt/1RADtC5

Beginning programming – bootcamps, self study, or back to school? via /r/learnprogramming


Beginning programming – bootcamps, self study, or back to school?

I have a full time job that pays well, but I hate every minute of it. Learning programming is something that appeals to me as a career opportunity in order to actually enjoy my work. Like the title says, I'm a beginner. However, I want to dedicate 15-20 hours per week to start gaining real programming skills and need a good starting point. I've looked at several online programming boot camps, free courses, and even university masters programs. What would you recommend in order to help me learn and potentially end up with a new career?

Edit: started doing some intro to ruby this week (~20 hours) and its been very enjoyable

Submitted March 31, 2016 at 07:04PM by ChefBoyOG_412
via reddit http://ift.tt/22T78B3

I want to learn how to make VBA macros for an obscure piece of software. via /r/learnprogramming


I want to learn how to make VBA macros for an obscure piece of software.

My only 'programming' experience is writing scripts for another obsure programme STATA, of which there is almost no overlap.

The programme I want to create macros for is Asta PowerProject, if it matters.

I know almost nothing about macros; but looking through a few tutorials and have a trawl through the object library it seems PP has almost no organisation, with most objects just being allocated numbers.

There are very slight similarities between PP and excel, but the functionality couldn't be further apart.

Have any of you had any experience tackling projects such as this, and any tips for beginner when there're no tutorials?

Submitted March 31, 2016 at 07:17PM by Ironic_Grammar_Nazi
via reddit http://ift.tt/1RADqWS