5,676 Posted Topics
Re: This is not a code snippet. This is a help question. Read the Rules before posting. | |
Re: [QUOTE=hermann87;1116717]The problem here is that although I manage to rename the file name from "unsaved.txt" to whatever the user enters, the global char* variable ([B]fileName[/B]) won't change and remain "unsaved.txt" so the next time I try to write something new into this file it will still create a new "unsaved.txt". … | |
Re: If you are having trouble with step 2, you should not have any code for step 3 and beyond. Edit out all the stuff you cannot test without step 2 being finished. Then perfect step 2. Add step 3 and make sure it works. Then start adding step 4, a … | |
Re: For example, your wrapper could keep track of all the memory allocated and deallocated. This would help you make sure you aren't attempting to deallocate twice, or not deallocating at all. | |
Re: [QUOTE=Gaiety;1115279]Yet Another Version of Findind a Prime number: [CODE] snipped [/CODE] i Hope this is the Efficient Version of All. Any other ways, Plz Welcome.[/QUOTE] I hope this is a joke. Please, do not take this code seriously... :icon_rolleyes: | |
Re: In [ICODE]AddNewElmnt()[/ICODE] you never checked the list to see if the character entered is already there. Check before adding. | |
Re: My questions are: Is this a bad cut & paste? If not: Who wants you to deal with this piece of trash code? When will you [I]ever[/I] do something like this (and keep your job)? Why do people insist on teaching this crap? | |
Re: [QUOTE=hauda67;1116643]What am I doing wrong? [/QUOTE] Not reading [url=http://www.daniweb.com/techtalkforums/faq.php?faq=daniweb_policies]this[/url] and [url=http://www.daniweb.com/techtalkforums/thread78223.html]this[/url] as requested, and assuming we are psychic. | |
Re: Because in the first case, the pointer [B]p[/B] is pointing nowhere. You defined the pointer, but never pointed it to space for the data. In the second, you allocated data space, and the address was placed into the pointer. But the only reason it didn't segfault is luck. The space … | |
Re: [url=http://www.gidnetwork.com/b-38.html][B]FORMAT[/B]!!!![/url] How do you expect us to read that?!?! Use the [B]PREVIEW [/B]button and if you don't like what you see, neither will we -- fix it! If your pumps hold 100 gallons and you ask for more than 100 gallons, the pumps at that station can't handle the requests. … | |
Re: Allocate a large temporary chunk of memory when recording starts. If you need more space, allocate another temporary chunk -- not one at a time -- to save time. Keep track of your chunks. When you stop recording, Allocate one more chunk just large enough to hold the entire recording … | |
Re: [QUOTE=zangetsuu;1113830]my function was working all fine and dandy but boring until my friend separated the function for me which we are suppose(required by teacher) to do and now my program stops after i enter the first and last name ( i was the one that added multiple return 0;) i … | |
Re: This is [B]NOT[/B] a code snippet, this is a help request. Post properly. Look up what a [I]code snippet[/I] is if you are unsure. | |
Re: [QUOTE=ELBUF;1113949]That first return statement is shown indented a lot, but I have it fine in my code. It pasted strangely, [/QUOTE] Convert TABs to 4 SPACEs. TABs don't work well on forums. | |
Re: My initial reaction is it needs whitespace. 1) Indent 3-4 spaces, not 1 2) More spaces on a line [iCODE]for (int j = 0; j < dim2; j++)[/iCODE] [iCODE]c.mat[i][j] += this->mat[i][k] * x.mat[k][j];[/iCODE] 3) Blank lines between logical sections Makes the program more readable. | |
Re: [QUOTE=sdh;1114458]the prototype of main is already written in the header files.[/QUOTE]He said it was solved. [QUOTE=sdh;1114463]u hv not written void main()[/QUOTE] No he not wrtn tht. Dun writ leet spk, use ful engsh so ppl wth bd englsh cn unnerstnd. This is part of the [url=http://www.daniweb.com/techtalkforums/faq.php?faq=daniweb_policies]Forum Rules[/url]. | |
Re: Recommendation--- Start over. Write the input function. Test it. Write the display function. Test it. you can copy the code from the current code to make it faster, but from now on *never* write the entire project without compiling and testing often. Write it in segments. | |
Re: [QUOTE=me_roy;1114720]Hi all, I am stuck here after several hours tried. Here the thing. I have txt file that contain float data (1 column and many row) such like this (4 float data): 0.799 0.851 0.926 1.000 Then i want to read it as array. My code is work until this … | |
Re: You mean like Batman and Robin? The Tick and Arthur? Thelma and Louise? Spiderman and Seabiscuit? | |
Re: [B]assign5.cpp:83: error: too many arguments to function âvoid Sort(cStudent (&)[30], int)â[/B] Well, the function [B]Sort[/B] has more parameters in the call than the function is designed to take. Hope that helps... | |
Re: [QUOTE=adnan.siddique;1112514]check this code[/quote] OK... [CODE]#include<stdio.h> # include <stdlib.h> int main() { int x = 0; printf("plz enter a number : ");[/code] Improper English. It's spelled "Please" [code] scanf("%d",&x); int y = 2 , z = 0; int * factors = (int*)malloc(100 * sizeof(int)); [/code] Declaring variables [I]after[/I] executable statements is … | |
Re: [QUOTE=XiaO yuEn;1112714]nput a number between 1-9, then choose 2 character, e.g: * and =. The sample output: Enter number: 5 Enter character: * = * == *** ==== ***** I had tried many times, but don't know where i was doing wrongly. Please help, thanks! [/QUOTE] We don't know what … | |
Re: [QUOTE=iammfa;1112751]Thanks Fbody for trying help me, I paste your corrected code but compiler gave me error:[/QUOTE] Proof positive -- if you [I]give[/I] an answer to someone, they will just copy and paste your solution into their code rather than try to [I]understand[/I] what you wrote and [I]fix[/I] their code. [B]iammfa[/B] … | |
Re: [QUOTE]i think i have the best one[/QUOTE] You violate [B]Salem[/B]'s 2nd rule and you think your solution is better? Think again. And your switch statement is terrible. And you used [iCODE]scanf("%s",str);[/iCODE], too. Very dangerous... | |
Re: Isn't a vector automatically sorted? Or am I thinking of something else? | |
Re: Depends on what you're trying to do. With all the '[B]#[/B]' signs and no formatting, the code is too hard to follow without some explanation. Plus you should always [I]explain[/I] what you're doing and not force us to read, understand, digest, and debug your code. Remember, [I]we[/I] didn't write it … | |
Re: [QUOTE=hag++;1112121]That will work but a function should really stick to only doin one thing... either calculation or cout, since this is not a complex task. [CODE] float circle_area(float radius) { return PI * radius * radius; } [/CODE] Then do the cout's in main[/QUOTE] This thread needs no more help. … | |
Re: [I]Leap[/I] was great too. Too bad they edited out the copyrighted music for the DVDs. Same with [I]Greatest American Hero[/I]. | |
Re: IMAO spoonfeeding should be an offense. But the Rules as written allow it. This has been discussed before and while spoonfeeding was not encouraged, what could we really do about it? Infracting is too harsh but that's the only 'punishment' we have. | |
Re: In [ICODE]cCourselist::Load()[/ICODE], why are you passing in [ICODE]Infile[/ICODE]? If you aren't using it anywhere else, just define it locally where you need it. Same with [ICODE]Outfile[/ICODE]. | |
Re: You forgot the [ICODE]#endif[/ICODE] The correct way of doing what? What are you trying to do? | |
Re: Look again at what firstPerson gave you and try to understand what he wrote. It answers your question -- unless you didn't ask the right question... | |
Re: Not a clue what you want. Think through your question carefully and give us enough information to understand the problem you're having. | |
Re: [QUOTE=jonsca;1111231]You have to pick one of your threads, don't just keep adding to both. [/QUOTE] [QUOTE=schoolboy2010;1111234]sorry.... was a mistake... reply here... or there... anywhere is fine.....[/QUOTE] No it isn't. "[I]Anywhere is fine[/I]" doesn't solve the problem. Other thread closed. Problem now solved. | |
Re: No, what the problem is your understanding of numbers. 10.1 is identical to 10.10 is identical to 10.1000000 Each is 10 and [B]1[/B] tenth. It doesn't matter how many zeros you add. Therefore, 10.5 (10 and [B]5[/B] tenths) > 10.10000000 | |
Re: [QUOTE=smbee;1106621]I am new to C programs. I have tried to write the code for game of life. I started with just the first part. But its still not done. There are some errors. could you please point out where I am wrong?[/QUOTE] Here are the first places where you are … | |
Re: When they pass in the list address to delete, if it hasn't been initialized, don't delete it. Return an error code. | |
I have a page with a navigation column and a data column that I wish to control separately, both sides use forms. When I scroll down and click on a button on navigation side I want the data side to change accordingly but I want the nav side to stay … ![]() | |
Re: [QUOTE=makan007;1109694]"I am trying to display an array of digits using rand. My final result need to be: 1) Output all digits <=40 to the left side of array 2) Output digits > 40 to the right side of array[/QUOTE] I was unaware arrays had sides. What do you mean? [QUOTE=makan007;1109694]Prob: … | |
Re: [QUOTE=firstPerson;1109766]Although I think it could be called before main.[/QUOTE] Impossible. [I]Nothing[/I] can be called before [ICODE]main()[/ICODE] | |
Re: [QUOTE=trevorthecat;1110170]Thanks. I switched the order of the cout statement and sort call, and now I get 10 -numbers and 10 random numbers sorted. Not sure why the first ten are messed up though?! Thoughts? [/QUOTE] My thought is "[I]why the first ten are messed up[/I]" explains nothing? No one but … | |
![]() | Re: With what? You gave us nothing to help with. Did you forget to read the Rules and the sticky posts at the beginning of the forum? |
Re: You do not want your variable to be [ICODE]static[/ICODE]. Set [ICODE]lowest_int[/ICODE] to the first value in the parameter list, then check all the others. | |
Re: Your program tried to access outside the bounds of your variables -- for example trying to access [ICODE]var[20][/ICODE] when the definition is [ICODE]int var[10];[/ICODE] | |
Re: Oh No!!! Not the String/scanf() faux pax!!!! [CODE] scanf("%s",name); scanf("%s",state); scanf("%s",rating); [/CODE] Please [url=http://www.gidnetwork.com/b-62.html]read this[/url] | |
Re: Rewrite your look so you don't call [iCODE]main()[/iCODE] to start the loop again. | |
Re: And why are you claiming [I]console apps[/I] are not [I]programs[/I]? How do [url=http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla:en-US:official&hs=13n&defl=en&q=define:computer+program&ei=Uf1YS5qMKJHSMpG42IMP&sa=X&oi=glossary_definition&ct=title&ved=0CAcQkAE]these definitions[/url] not fit a console app? :icon_wink: |
The End.