| odirtyredo (1) | |||
|
I searched the internet front and back looking for the answer to this problem. "Do programming exercise 4, but use new to allocate a structure instead of declaring a structure variable. Also, have the program request the pizza diameter before it requests the pizza company name." I have a minor in computer science but since it has been a while since I have done any programing I wanted to put myself to the test and reinforce what I know and see if I can learn more on my own. Anyway I ran into this problem and could not find a good example to emulate so after many attempts I figured it out and I want to share my code with anyone who may run into this problem in the future or so that I can find it if I need to in the future. I used MS visual studios so adjust to your compiler. for the first question always answer 3 or modify the code
| |||
|
|
|||
| Zhuge (2871) | |
|
Why is this in the article section? It doesn't look that good... You could make better use of std::strings instead of char[] for the string data; also you ask how many companies you want despite having allocated space for only 3. This means your first loop will write beyond your area for numbers greater than 3. You cin>> statements also completely die if you input any non-numerical data for the diameter or weight. stdafx.h is not necessary even for VS compilers; you only need that if you enable precompiled headers, and even then I believe that stdafx is just a default name that VS happens to use for the precompiled header. system("pause") has nothing to do with your compiler either; it's all about the OS, and that command works only for Windows. There are other more portable options available that would allow a different user to get the same functionality instead of having to delete the line. tldr: Could be improved quite a bit, and TBH I don't think we need an article for this topic. Perhaps it would have been better elsewhere? | |
|
|
|