6,741 Posted Topics

Member Avatar for rockerjhr

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].

Member Avatar for rockerjhr
0
115
Member Avatar for gaurav_13191

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) …

Member Avatar for vinitmittal2008
0
149
Member Avatar for helpfullProgram

Can you post a complete program that exhibits the problem? Troubleshooting through snippets is generally unproductive.

Member Avatar for Narue
0
199
Member Avatar for rhn94

[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.

Member Avatar for rhn94
0
738
Member Avatar for barryt

[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 …

Member Avatar for happygeek
0
221
Member Avatar for ~s.o.s~

What a weak season. At least there's [i]one[/i] show I'm looking forward to (Kimi ni Todoke).

Member Avatar for ~s.o.s~
0
196
Member Avatar for MasterGberry

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".

Member Avatar for MasterGberry
0
147
Member Avatar for moroccanplaya

"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.

Member Avatar for Dervish1
0
84
Member Avatar for motigeva

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 …

Member Avatar for rafi1082
0
123
Member Avatar for endsamsara

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 ( …

Member Avatar for endsamsara
0
160
Member Avatar for moroccanplaya

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].

Member Avatar for Shankye
0
150
Member Avatar for crimes

[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).

Member Avatar for crimes
0
105
Member Avatar for ~s.o.s~

>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:

Member Avatar for Borzoi
0
726
Member Avatar for atoklas

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 …

Member Avatar for milkz
0
220
Member Avatar for bnelle01

There's a forum called "Legacy and Other Languages". You can pose BASIC questions there.

Member Avatar for Narue
0
125
Member Avatar for daviddoria

[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 …

Member Avatar for jon.kiparsky
0
430
Member Avatar for moroccanplaya

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] …

Member Avatar for moroccanplaya
0
95
Member Avatar for bflack

[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 …

Member Avatar for Shankye
0
193
Member Avatar for Dean_Grobler

[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:

Member Avatar for Kraai
0
105
Member Avatar for akamini

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; …

Member Avatar for Narue
0
192
Member Avatar for gouzou

[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 …

Member Avatar for gouzou
0
148
Member Avatar for moroccanplaya

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]

Member Avatar for Narue
0
78
Member Avatar for zerocool123

>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.

Member Avatar for Narue
0
1K
Member Avatar for acer07
Re: Dani

[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.

Member Avatar for ~s.o.s~
-3
126
Member Avatar for thunderwolf07

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 …

Member Avatar for thunderwolf07
0
79
Member Avatar for moroccanplaya

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, …

Member Avatar for moroccanplaya
0
157
Member Avatar for Castiel1631

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 …

Member Avatar for Castiel1631
0
2K
Member Avatar for Shankye

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.

Member Avatar for vinitmittal2008
0
553
Member Avatar for hystaspes

[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, …

Member Avatar for hystaspes
0
124
Member Avatar for gahhon

*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) { …

Member Avatar for Shankye
0
78
Member Avatar for rhoit

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 …

Member Avatar for rhoit
0
542
Member Avatar for Tiancailee

[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.

Member Avatar for Narue
0
128
Member Avatar for hoceandress
Member Avatar for islam-morad

[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 …

Member Avatar for islam-morad
0
133
Member Avatar for berwick53

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]

Member Avatar for berwick53
0
97
Member Avatar for bookmark
Member Avatar for Narue
0
277
Member Avatar for bkoper16

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.

Member Avatar for Narue
0
202
Member Avatar for atramposch

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). …

Member Avatar for Shankye
0
159
Member Avatar for berwick53

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) { …

Member Avatar for Narue
0
104
Member Avatar for tomtetlaw

[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 …

Member Avatar for tomtetlaw
0
97
Member Avatar for cwarn23

Yes, you can buy motherboards that have multiple CPU slots. How do you think we managed multiple cores before multi-core processors came out? ;)

Member Avatar for cwarn23
0
63
Member Avatar for happygeek

My name is Julienne Walker and I'm a: [LIST] [*]Anime/manga geek [*]Linguistics geek [*]Gaming geek [/LIST]

Member Avatar for Chatterbox721
0
758
Member Avatar for whatsgoin'on

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.

Member Avatar for krssanthosh
0
174
Member Avatar for ritcherjd

>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 …

Member Avatar for angelique28
0
1K
Member Avatar for freebanana

[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 …

Member Avatar for jon.kiparsky
0
130
Member Avatar for HELL DRAGON

[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 …

Member Avatar for mechbas
0
193
Member Avatar for hyperion

[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 …

Member Avatar for Narue
0
164
Member Avatar for Lerilaine

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 …

Member Avatar for Narue
0
1K
Member Avatar for precila

[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 …

Member Avatar for AndreRet
0
202
Member Avatar for lagvino_els

[url=http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_andersson.aspx#delete]Clicky[/url]

Member Avatar for Narue
0
104

The End.