@KCfromNC - Now that's pretty darned elegant. I haven't seen that way before.
Type: Posts; User: Futomara
@KCfromNC - Now that's pretty darned elegant. I haven't seen that way before.
One thing that is unclear is why pointers shouldn't be used. I understand they are better for memory management. So, why not always use them?
@laserlight - My expectation is to learn the best coding practices, whether it be instructor 'taught' or through self-teaching. I generally learn better with the latter. However, it is always nice to...
I prefer to ask it here where I can get an answer I can understand. Plus, I won't always have an instructor. What then? Exactly, I'll be back here asking for help.
Tater,
*t[i] = 0;
The above code is not proper pointer syntax. Just to verify this, I made changes to my source, and it errors out.
I only need to initialize each element and then I am...
Yes, I've gone through several runs and it does not crash and returns the proper results.
Basically, I left everything as is except instead of declaring total as a pointer I keep it as an array....
Jim,
We were not taught this in class. I tried it and it works. What if I change it like this:
double total[6];
and keep the other (affected) lines of code like this:
Total is an array. Pointer syntax is to be used. If I am improperly initializing it, then show me how. Your code seems to change total from a pointer to a primitive and it compiles with a list of...
Now, I am converting the arrays to pointers. Hopefully I don't need to start a new thread. Please tell me if I do. When I compile, I get this error:
warning C4700: uninitialized local variable...
Jim,
Thank you!! You are helping me understand C programming much better. My instructor isn't that great, obviously, which is why I sought help elsewhere. I seem to be making simple mistakes. I...
Okay, so now my output is like this:
Employee Total Pay
------- -----------
Pete Rose 112233.00
Pete Rose 332211.00...
Without the ampersand the program crashes.
There are no global variables allowed either. So the name array is within main().
So, how do I get the array to enumerate properly? Notice it is only...
I am creating simple program to take input of an employee number (1-5) and how much their paycheck was. I loop until no more entries are desired. Then, I output their name (based on their employee...
Won't that cause a problem with this function when it's called here (red)?:
/*========================menu()=================================================*/
int menu()
{
int choice;
...
I got it!!
/*=======================add()==================================================*/
void add()
{
int prodNum, prodType, prodQuant;
double prodCost, prodPrice;
char choice;
Well, you are right. It fails when I try to go through the loop again. Here is the current code I'm testing:
/*=======================add()==================================================*/...
I went back through and found I didn't change a couple min and max to doubleMin and doubleMax. The program now outputs properly.
Sierra Sporting Goods
Enter the Product Number: 1 to 9999: 1...
Thanks for taking another look at my code.
In testing out your solution, the program crashes because of the clearerr(fp) citing "The variable 'fp' is being used without being initialized."
If I...
I want to re-explain the problem, as I still do not have all the solutions.
The assignment is to modify a prior lab. Here are the relevant lines of unmodified code from the prior lab:
...
I don't think this will work because getint() is called in the menu() function with actual values instead of variables.
int menu()
{
int choice;
title();
Correct... this is not what I want. I want it to cycle through each item.
Yes, but I don't know what to change in those functions.
Yes, each line is min, max. I showed an example of...
Yes, the input file is as follows:
1 9999
1 5
1 50
5.00 900.00
6.00 1000.00
If I change the line to:
while (fscanf(fp, "%lf%lf", &min, &max) != EOF)
not only does it still not cycle through all inputs, but my output is:
I did refer to the link the first time you suggested it There are two data types being called for. So, was I given the wrong advice? I don't see the solution.
The data in the text file is both...
I tried %f thinking it would pass the int's and the doubles. The numbers were still wrong. If I use %d, then when the value being passed is a double, it truncates the decimal portion. In addition,...