5,676 Posted Topics
Re: Every time you go throught the loop when **k** equals **i-1** you have a match. Start the **i** loop at **k+1** and get rid of the +1 elsewhere in that section. Also, the standard way to do loops is if you defined the array as `A[20]`, your loop is set … | |
Re: If you had string studentName; int grade not in a structure, how would you do it? | |
Re: > This functin is designed to go through the rows that I've allocated in my dynamic array and see if it the user inputed a valid lab number. It doesn't do anything. All the function does is increment a pointer and the steps. And `if (*rowWalker == NULL)` is TRUE … | |
Re: No. They are just a different way of doing it. And you'd still need a loop anyway. IMO, your technique is just fine without the class. Although, if you notice, every one of your input sections look exactly the same: cout << "Enter the number of XXX Dollar Bills you … | |
![]() | Re: I use the undo option when I decide I want to remove my vote, not because I accidently added a vote. > I still think it would be a good idea to change the dropdown (wording) to know if you've hover over an up or down arrow... No it wouldn't. … |
Re: >Why don't you try using FireFox. Its fast and sleek. > >> Patient: "Doctor, it hurts when I blink." >> Doctor: "Don't blink." Isn't it more like: Person A: My car needs a brake job. Person B: Why don't you get a new car? | |
Re: /* This function is used to calculate how many of each coin is needed */ int RepeatedlyCoins (int ¢s, int coin_worth) { What is the first parameter in this function definition? Never seen a variable like that. | |
Re: Line 38 you probably want `diff_w` and `suitor_w` Sort on the value you want (`diff_w` or `diff_h`). Make sure you swap **all** the arrays. Then output your data for that sort. | |
Re: > please write this code for me!! Im in dire need!! Why do you people continually ask us to do your work for you? This constant request for cheating is really getting annoying! Find something else to do. | |
Re: > can you keep it like a computer science I beginner level with the same functions and variables as i had up top So what you want is to for him rewrite your homework for you so it looks like *you* wrote it, not an expert? Wouldn't it be better … | |
Re: And yet [I]another[/I] hijack bump to a 6 year old thread. I don't think he read even one thing he was asked to read upon registering, so why would he read the important stickys and announcements at the top of the forum itself? | |
Re: You need to break up your loop into multiple loops. 1st) read the entire file in one loop 2nd) sort the data using two loops 3rd) the rest of the program | |
Re: Either 1) print the ##### before you start the `while` loop 2) set a flag named **FirstLineFlag** to true before you enter the loop and set it to false after you print. You can work out the rest of the details. | |
Re: If you aren't sure how **find** works, you should forget all the other parts of the program for the moment and just program various uses of **find** until you understand how that works. That will make programming the rest of the task easier. | |
Re: If you consider MicroSluge awesome, I suppose so... 8] IMAO, I'd change color schemes quick so as not to be assiciated with *them* :o) | |
Re: Each peg is an array. Load peg 1 with the disks peg[0] = 1 peg[1] = 2 etc Each time you move a disk you must take the **last** value in the array and place it in the first **open** location in the new array/peg | |
Re: You were told [here](http://www.daniweb.com/software-development/cpp/threads/435399/shortcut-in-reading-a-.txt-file#post1869659) about `void main()`, *conio.h* You were told [here](http://www.daniweb.com/software-development/cpp/threads/435132/hello-c-experts#post1868257) about *conio.h*, `void main()`, putting non-code into your code to confuse us. You were told [here](http://www.daniweb.com/software-development/cpp/threads/432311/deleting-an-element#post1853891) and [here](http://www.daniweb.com/software-development/cpp/threads/432311/deleting-an-element#post1853925) about `void main()` And [here](http://www.daniweb.com/software-development/cpp/threads/432311/deleting-an-element#post1854009) about using `goto` [here](http://www.daniweb.com/software-development/cpp/threads/435243/do-i-have-to-start-a-new-discussion-whenever-a-question-is-solved#post1869159) again `void main()` was mentioned. And I know `goto`, *conio.h*, formatting … | |
Re: **nitin1** is correct. With a little more detail: Any number that starts with a zero is interpreted in base 8 (octal) rather than base 10 (decimal). Therefore your 011 is: `one 8 and one 1` rather than `one 10 and one 1`. | |
Re: Yes we can, but we can't read it because of the lack of formatting. [See this](http://www.gidnetwork.com/b-38.html) [See this too](http://www.gidnetwork.com/b-66.html) Do not use `goto`'s and get rid of the `label`'s | |
Re: Your code won't compile with that extra *meaningless* text at bottom of the program. | |
Re: 1) `void main()` is wrong. [See this](http://www.gidnetwork.com/b-66.html) 2) `conio.h` is non-standard. You do not need it. 3) [format](http://www.gidnetwork.com/b-38.html) your code properly. > i'm thinking of using an array...the code ive done would read the first line right? Right. >but i want to read as an array if it would be … | |
Re: What **type** did you enter with `scanf("%c",&option);`? What's the binary value of the input? What **type** did you compare with `case 1:`? What's the binary value of the test value? | |
Re: Good question. Write a short program and output the value. Does it compile properly? If so, what does it output? | |
Re: Output the values you use in the loop and see what they generate. When you see that the values are wrong, you then know what to look for to fix the problem. | |
Re: In your original description you said > Given number n ( n<=9999) Inputting a **string** is not a number. You need to rethink your program and reconsider [this](http://www.daniweb.com/software-development/cpp/threads/433882/simple-math-c#post1861728) suggestion. | |
Re: `array = new int [size];` Wrong syntax. Look up the correct syntax again. Also, what is the value of **size** at that point of the program? Hint: It's probably not zero. | |
Re: > can you please help me with this.. Sure we can, don't get your knickers in a twist! The best help you can get is [format your code](http://www.gidnetwork.com/b-38.html). Most likely your problem will become immediately apparent. | |
Re: **owenransen**, you are completely correct. The reason is the \ character defines the *next* character as an 'escaped' character. \n = new line \f = form feed \t = tab etc. So, `myfile=fopen("C:\Documents and Settings\Migs\Desktop\test.txt","r");` contains 2 escaped D's, 1 escaped M, and 1 escaped T (tab). That does not … | |
Re: Why are you using `fscanf()` to read a single character? The overhead is tremendous. `fgetc()` was specifically made to read a character. It's small and concise. | |
Re: What's `q=((2*i)+1);` supposed to be doing? If you wan tthe factorial of 7, why are you passing 15 to the function? Won't that give you 15! ? | |
Re: >Do i have to start a new discussion whenever a question is solved? Not if it's a continuation of the original program. Although if you *mark* it solved, many people will bypass the discussion. | |
| |
Re: > Is there a reason I can not do that with this code? Probably because the file isn't in the same directory as the .exe, as already explained. Alternatively you have *debug* turned on and it needs to be in the *debug* diectory of the project. | |
Re: > I really dont understand any of this... OK, translation: > You are going to convert feet and inches or pounds in this program. You will write a conversion program that converts feet into inches and inches into feet. It must also handle pounds (presumably into ounces). > You will … | |
Re: > Secondly, never, ever use gets, always use fgets, so not gets(sh); but fgets(sh, sizeof sh, stdin); it is safer since you can't overwrite the buffer,... And the exact same thing goes for using `scanf()` to read strings. It's as bad as `gets()`. | |
Re: 1) Stop putting your question into your code. Your question is **not** code. 2) `#include<conio.h>` -- don't use this. It's not standard and is not necessary. 3) struct BuyerInfo { int id; string fn; string mn; string ln; string ad; };BuyerInfo info; Why is the first semicolon in this line: … | |
Re: When I delete a post (as least one of my own) I click the DELETE button twice before it changes to UNDELETE. Sounds related to the refresh somehow. > Is it just me, or when you vote with a comment, does the comment not instantly show up like it's supposed … | |
Re: You know, you *could* ask a question or two that will lead us to understand what you are having trouble with and actually be able to lead you to a solution or two. | |
Re: 1) **side1** has no value so you are passing junk onto `myTriangle.setside1()` 2) `myTriangle.setside1()` is a void function and returns nothing, therefore you can't load that nothing into **side1** | |
Re: **The Dragon** gave you a major clue. Try reading about `fscanf()` and try some things. Testing is the best way to learn. | |
Re: > It is quite fundamentally flawed Agreed. And the [formatting](http://www.gidnetwork.com/b-38.html) is terrible. Calling `system()` is not necessary and not portable. When compiling on my Linux system the program doesn't work as advertised. On my Windows system I get nauseous with all the blinking screens. Too many convoluted IF statements where … | |
Re: > Is fputc() used to save in files? Yeas it can. But is it appropriate for *your* program? What did the tutorial tell you to do? >I know the logic d above u wrote,I actually want the syntax to store it in file after comparison Of course you do. It's … | |
Re: I would suggest you open your book and look at the chapter on arrays. your question is sooooo basic that it's in there. | |
Re: > this is a code from the book "the C programming language" by dennis ritchie I'm looking at the code in the book right now. Your code doesn't look like the code in the book. They wrote the code with indentation so that it's easy to follow. Look at the … | |
Re: Look up how `malloc()` and `free()` work | |
Re: What is the result of 10 % 10? How can that answer be used to output the value you want? | |
Re: Please [format your code](http://www.gidnetwork.com/b-38.html) so we can follow/read it |
The End.