6,741 Posted Topics
Re: Are you summing the actual values in the sequence or the index within the sequence? Because your code presently does the latter by adding [iCODE]i[/iCODE] to the sum instead of [iCODE]v[/iCODE]. | |
Re: I'm getting correct output for simple test cases. Perhaps you mean the output window is closing before you can see the results? If that's so, add a call to getchar just before returning from main: [code] int main() { int a[20],n,ctr=0,j=0; printf("\nEnter number of elements:"); scanf("%d",&n); printf("Enter array elements:"); while(ctr<n) … | |
Re: Can you post a complete program that exhibits the problem? Troubleshooting through snippets is generally unproductive. | |
Re: [B]>A computer program cannot test for a sound.[/B] I'm sure all of the programmers working on phonetic recognition algorithms (eg. Soundex) will be dismayed to hear that. | |
Re: [QUOTE=octavia;1417547]Yes,actually DaniWeb not so active. I never get right answer whenever i posted thread about my problem in programming or any. Normally less replies; sometimes, 0 replies. Seems not interesting my thread. I prefer whirlpool forum which is based in Aus.[/QUOTE] While it's possible that you're so advanced nobody on … | |
Re: What a weak season. At least there's [i]one[/i] show I'm looking forward to (Kimi ni Todoke). | |
Re: Can you post a main function that does absolutely nothing except present the issue? To be perfectly honest, it's too much effort to paste your code into a project and then divine what inputs are required to make it "not work". | |
Re: "wa+b" isn't a legal open mode. Most likely your compiler is interpreting it as "w" rather than "a+b". Any open mode with a base of "w" will truncate the destination file upon opening it. | |
Re: You already know the size of each element in the form of num_of_byte. First alter your swap macro to accept a byte count which will be passed to memcpy. Then replace your comparison (which is comparing the address of two pointers) with a predicate function that compares values. Look to … ![]() | |
Re: You're not even using a two dimensional array. But if you were, did it occur to you that you can do this? [code] for ( i = 0; i < ROWS; i++ ) { int col = coordenada ( array2d[i], target ); if ( col != -1 ) printf ( … | |
Re: I see a major discrepancy in your use of the input variable. Is it a char, or an array of char? Because either way you're misusing it [i]somewhere[/i]. | |
Re: [url=http://eternallyconfuzzled.com/arts/jsw_art_rand.aspx]This[/url] may be helpful. I think the real problem here is you're not seeding rand properly and expecting the default seed to be different each time (which it's not). | |
Re: >Are you married or not ? Yes. ;) >If yes then what did marriage change in your life, are the new found >responsibilities burdening you or making you a better person ? What [i]didn't[/i] it change? :rolleyes: | |
Re: The %[] specifier is a scan set. scanf will look for everything between the brackets and act accordingly. If the scan set begins with a ^ character, it means to exclude the characters in the scan set, otherwise include them. So [ICODE]%[^\n][/ICODE] means to read and store everything up to … | |
Re: There's a forum called "Legacy and Other Languages". You can pose BASIC questions there. | |
Re: [QUOTE=cscgal]Essentially, all the people who post without code tags would instead get frustrated and/or confused and simply not post at all.[/QUOTE] It's this focus on quantity over quality that drives clueful people away from Daniweb and attracts the dregs of the geek community. [QUOTE=cscgal]I am hesitant to follow in the … | |
Re: If you're accepting file names from stdin, a loop is pretty much the only option. You can streamline the process a little by giving users the option of simply typing all of the files at once: [code] printf("Files to archive: "); fflush(stdout); while (scanf("%s", filename) == 1) archive(archive_name, filename); [/code] … | |
Re: [B]>Location Value >and another is RValue which is Read value..[/B] Cute, but no. Your answer conceptually is fine, as it's not technically incorrect, but the question was what the 'L' in lvalue stands for. Historically, lvalue meant the left hand side of an assignment expression while rvalue meant the right … | |
Re: [B]>Because 90% of the threads in here is almost exact copies of the ones on DIC.. bleh [/B] Because 90% of the people asking questions post the same thing to as many forums as possible. :icon_rolleyes: | |
Re: I didn't look closely for bugs in your trim algorithm, but I did notice a problem in main at a glance. If you replace your main function with this one, does the error still occur? [code] int main(void) { char s[] = " Hello world "; printf(">%s<\n", trim(s)); return 0; … | |
Re: [B]>you can't copy a string into another by using = operator in c, use strcpy function[/B] While this is true (somewhat), that's not the problem since the OP is using pointers. The problem is that the pointer is pointing to a local variable. When add_network returns, network_name is destroyed and … | |
Re: It's recommended that you follow the normal path of calling and returning from functions. Organize the flow of control to fit that practice and all should be well. Example: [code] int main(void) { int option; while ((option = menu()) != 3) action(option); return 0; } [/code] | |
Re: >required to use gets Slap your teacher for me. He's a moron. There's [b]never[/b] a good reason to use gets, and anyone who requires it clearly has no idea how C works. | |
Re: [B]>This is weird, if not creepy.[/B] More like creepy, if not outright disturbing. Even more so in Dani's case due to easy to find real world contact information. At least when crazy stalkers start breathing heavy around me, I'm less frightened because they're unlikely to show up at my doorstep. | |
Re: In the case of %f, it's the field width and precision. The field width specifies the minimum number of characters that will be printed. The field will be padded with whitespace if the value is smaller than the field width. If it's larger, nothing special happens. The precision specifies the … | |
Re: Just fill the buffer back up and use the resulting count. The previous contents will be overwritten: [code] #include <stdio.h> #include <stdlib.h> int main(void) { FILE *in = fopen("test.txt", "r"); char buffer[10]; size_t n; if (in == NULL) { perror(NULL); return EXIT_FAILURE; } while ((n = fread(buffer, 1, sizeof buffer, … | |
Re: I see quite a few issues, but the most immediate is a misunderstanding of how pointers work when passed to a function. Your initMyString will completely fail to do what you're expecting because the parameter is a [i]copy[/i] of the argument, not a reference to it. See [url=http://eternallyconfuzzled.com/tuts/languages/jsw_tut_pointers.aspx#ptusing]this article[/url] for … | |
Re: ch should be int if you want to test for EOF, and you have portability issues with such constructs as ch-'A'. I've seen worse, but you have some learning to do before I'd recommend posting examples for others to learn from. | |
Re: [B]>Is there any drawbacks for using "this" pointer?[/B] It's harder to read and more work to type? [B]>Is it a good practice to use "this" all the time and whenever possible?[/B] When it comes to this particular usage, I think [icode]this[/icode] should be avoided except to resolve an ambiguity. However, … | |
Re: *sigh* Okay, here's a better example. Instead of trying to cram letters into a smaller array, I've used an array that covers the whole range of the char type and then filter the output. It should be easier to follow: [code] #include <stdio.h> #include <ctype.h> #include <limits.h> int main(void) { … | |
Re: Short answer: cout is interpreting the object as a bool due to the volatile qualifier. It's a quirk of overloading for the << operator. Long answer: A volatile pointer can't be converted to a non-volatile pointer without an explicit cast, so neither the char* nor the void* overload can be … | |
Re: [url=http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx]This[/url] might help. If not, let me know what parts you didn't understand so I can make it better. | |
Re: >i'm using the standard header file!!the using namespace std; Good for you? | |
Re: [B]>How could a JFrame, an image file, a video file or a text file etc... >be represented by only a bunch of 000000's and 1111111's?[/B] 0 and 1 are really just a convenient notation for the electrical pulses a binary computer uses to generate streams of data. Those pulses are … | |
Re: Assuming we're talking about a std::string object and not a pointer to char: [code] stringstream ss; ss<<"CASH WITHDRAWAL "<< safe_input2 <<" GBP"; data[person].history[data[person].trans] = ss.str(); [/code] | |
Re: Did you try declaring the variables a, b, and c? :icon_rolleyes: | |
Re: Addressing the error only (there are other issues), you're passing wname, which is an array of char. The function expects only a single char, not an array of them. | |
Re: I'm not sure what drug you guys are taking that kills brain cells, but it seems like everyone and his brother is having trouble with passing pointers to functions and changing where they point to. But here's an example that does what you want (without using dynamic memory, for simplicity). … | |
Re: Use fgets to read each line, then your favorite CSV reading algorithm to separate the fields. Here's one easy way to do it if you're not using a complex form of CSV: [code] #include <stdio.h> #include <stdlib.h> int main(void) { FILE *in = fopen("data.txt", "r"); char line[BUFSIZ]; if (!in) { … | |
Re: [B]>Sometimes they're being set to other addresses but still being unitialized, and >they pass tests like if(!ptr), causing an unhandled access violation error.[/B] That's the whole point, genius. If you're trying to use an uninitialized pointer, that's a [B]Bad Thing[/B]â„¢, and it should be immediately fatal as it's a programming … | |
Re: Yes, you can buy motherboards that have multiple CPU slots. How do you think we managed multiple cores before multi-core processors came out? ;) | |
Re: My name is Julienne Walker and I'm a: [LIST] [*]Anime/manga geek [*]Linguistics geek [*]Gaming geek [/LIST] | |
Re: It takes about five minutes to figure out. Just take a few coins and use queue-like operations to simulate the pushing and popping of a stack. The nice thing about stacks and queues is that the concepts are so simple you can easily diagram them with minimal effort. | |
Re: >error LNK2001: unresolved external symbol _clrscr clrscr is a frivolous function that only an ignorant newbie or a blatant antisocial prick would use at the start of their program (and usually everywhere else too). You can safely remove it. You may also need to change getch to _getch to compile … | |
Re: [B]>Anyway do you think it's true that if you have 'truck driver' on your resume IT people will not hire you?[/B] No, it's not true. [B]>That's my dad's logic but I think it's absurd[/B] Yes, it [I]is[/I] absurd. A gap in one's employment history would be far worse than a … | |
Re: [B]>are there any specific video tutorials for people like me ?[/B] Doubtful, and I wouldn't trust them if I knew of any. As a system analyst, your recommendations will be made on a case by case basis and somewhat subjective based on your experience. Much like with programming there are … | |
Re: [B]>But even after AppendNode call, rootnode is NULL.[/B] Yes, because any changes to rootnode within AppendNode will not persist back to main. In AppendNode, rootNode is a [I]copy[/I] of the pointer, not a reference to it. I suspect you need more study on how pointers work between functions: [code] #include … | |
Re: You only need to realloc the first dimension, then malloc the newly added pointers. In this case only one new pointer is being appended to the "array", so it could be as simple as this: [code] res = realloc(res, sizeof(*res) * count); res[count - 1] = malloc(z); [/code] [I]<insert caveats … | |
Re: [B]>Private data members cannot be accessed outside the class.[/B] Yes. [B]>When a class inherits a base class, all the data members except the private get inherited into it.[/B] Private members [I]are[/I] inherited, but not accessible from the child class. [B]>So if we want data members to be accessible to only … | |
Re: [url=http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_andersson.aspx#delete]Clicky[/url] |
The End.