2,384 Posted Topics

Member Avatar for DavidDD

[url]http://www.dinkumware.com/manuals/default.aspx?manual=compleat&page=string2.html#getline[/url] The third parameter is the delimiter character (when omitted, the delimiter is the newline character). So getline stops reading on a space (which it discards). Or, in a loop, tokens (word) are space-delimited. [url=http://www.daniweb.com/techtalkforums/post155265-18.html]Avoid Loop Control Using eof()[/url]

Member Avatar for DavidDD
0
350
Member Avatar for merse

[QUOTE=merse;1102767]It is possible to write, but the compiler dont find the function when I want to use func(x): [CODE]template <class T> double func(const double& x, const double[COLOR="Red"]& error = 0[/COLOR]) {...}[/CODE][/QUOTE] Reference to ... what? NULL? Are you passing by reference when you don't need to? Are you using T …

Member Avatar for Dave Sinkula
0
100
Member Avatar for asa88

I find the above a bit confusing. What's wrong with having a function that takes an unsigned value and displays the bits? Doesn't that then do the 2's complement thing automagically? [CODE]#include <iostream> /** http://www.daniweb.com/code/snippet216408.html */ void bits_uint(unsigned int value) { unsigned int bit; for ( bit = /* msb …

Member Avatar for jonsca
1
225
Member Avatar for Agni

[ICODE]-pedantic[/ICODE] [QUOTE]main.cpp:4: error: ISO C++ forbids variable-size array `arr'[/QUOTE]

Member Avatar for Agni
0
139
Member Avatar for nshh

[QUOTE=gerard4143;1105357]The Complete Reference C by Schildt[/QUOTE]That one definitely needs a version number to go with it. I've heard he's fixed things in newer versions, but the early ones are well know sources of disinformation: [URL="http://www.catb.org/~esr/jargon/html/B/bullschildt.html"]bullschildt[/URL] @OP: did you read the [URL="http://www.daniweb.com/forums/thread50370.html"]sticky[/URL]?

Member Avatar for Dave Sinkula
0
101
Member Avatar for Japus

[CODE]for (int i = 0; i <[COLOR="Red"]=[/COLOR] tagsize; ++i)[/CODE] This goes one beyond the array bounds. [CODE] int tagsize = 50; char buffer[tagsize];[/CODE] Since tagsize is not const, it would seem that you are using a nonstandard extension. Be aware of that.

Member Avatar for Salem
0
188
Member Avatar for phil750

It seems to me that you want to be reading the file data into an array of structures rather than simply a single "struct" of ProcessID, Quantum, Priority. And then when you have all of the data from the file stored in this array of structures, [I]then[/I] you go forward …

Member Avatar for phil750
0
111
Member Avatar for Dave Sinkula

Can you add the icode button to the Quick Reply? I tend to use it (as previously mentioned ad nauseum :icon_razz:) for anything in which fixed font helps text stand out better. In fact, I probably use it more than code tags. I would find the button link handy. Another …

Member Avatar for ablitz
4
349
Member Avatar for DavidDD
Member Avatar for DavidDD
1
129
Member Avatar for mimis

[QUOTE=mimis;1103763]Can I do that sort with STL?[/QUOTE] Do you need to have parallel arrays, or can you put them in a container of some sort? [CODE]#include <iostream> #include <algorithm> struct T { int a,b; }; void display(const T *data, size_t size) { std::cout << "A B\n"; for ( size_t i …

Member Avatar for mimis
0
113
Member Avatar for King Dede

[url]http://www.compilers.net/Dir/Compilers/CCpp.htm[/url] [url]http://www.compilers.net/Dir/Free/Compilers/CCpp.htm[/url]

Member Avatar for Stefano Mtangoo
0
325
Member Avatar for ContactaCall

In words, what is this TTS function supposed to do? [CODE]#include <stdio.h> #include <string.h> #include <ctype.h> int main(int argc, char**argv) { const char delim[] = " "; char text[] = "231 number 73 word 1 2"; char *token = strtok(text, delim); while ( token ) { if ( isdigit(*token) ) …

Member Avatar for ContactaCall
0
250
Member Avatar for ContactaCall

This is an idiom to avoid ([URL="http://www.daniweb.com/forums/post228873.html#post228873"]*[/URL]): [CODE]for (i = 0; [COLOR="Red"]i < strlen(ch)[/COLOR]; ++i)[/CODE] This is more confusing than it ought to be: [CODE]pstr = strtok([COLOR="Red"]'\0'[/COLOR], " ");[/CODE] You mean NULL. Use NULL.

Member Avatar for Dave Sinkula
0
418
Member Avatar for johndoe444

[url]http://eternallyconfuzzled.com/tuts/languages/jsw_tut_pointers.aspx#reftptr[/url]

Member Avatar for gerard4143
0
95
Member Avatar for Fbody
Member Avatar for Fbody
0
1K
Member Avatar for clutchkiller
Member Avatar for Fbody
0
79
Member Avatar for Dani

[QUOTE=WaltP;1028252]2) I prefer [I]multiquote[/I] rather than [I]Flag to Quote[/I]. The former tells me what the button does. The latter tells me very little.[/QUOTE]Yup. I need the flyover to remind me that it means multiquote. [QUOTE=niek_e;1028264][QUOTE=WaltP;1028252]3) I want the [I]Reply without quote[/I] back. I for one use it a lot.[/QUOTE]Just press …

Member Avatar for feoperro
3
941
Member Avatar for BoB3R

[QUOTE=BoB3R;1100595]So it looks like this Ive got a file named "b.txt" created by me in windows and i want to read from it and print it on screen thats it and i didn't know it would be so complicated.[/QUOTE]:shrug: [CODE]#include <stdio.h> int main(void) { FILE *file = fopen("b.txt", "r"); if …

Member Avatar for kvprajapati
0
172
Member Avatar for hnf1991

[url]http://www.daniweb.com/tutorials/tutorial45806.html[/url] There are links there for "Read an Integer from the User..." (This would be approach (1) from above.)

Member Avatar for Dave Sinkula
0
87
Member Avatar for mrnutty

[QUOTE]Whats up with the edit function ? I can't edit my own code ?[/QUOTE]Ah, yes. I too miss the old days when the snippets section was first begun. There was unlimited editing time for the author, which I would still find useful today. And the formatting in this section was …

Member Avatar for Dave Sinkula
2
3K
Member Avatar for isrinc

Watch more closely what you're doing with the printf's. [CODE] printf ("3 Vals Read: %5.3f %5.3[COLOR="Red"]f[/COLOR] %5.3[COLOR="Red"]f[/COLOR] \n", [COLOR="Red"]f[/COLOR], [COLOR="Red"]p[/COLOR], [COLOR="Red"]q[/COLOR]); printf ("2 Vals Read: %8.3f %8.3[COLOR="Red"]f[/COLOR] \n", [COLOR="Red"]r[/COLOR], [COLOR="Red"]s[/COLOR]); printf ("1 Val Read: %7.2f \n", [COLOR="Red"]t[/COLOR]); fprintf (outFileOne, "%5.3f %5.3[COLOR="Red"]f[/COLOR] %5.3[COLOR="Red"]f[/COLOR] \n", [COLOR="Red"]f[/COLOR], [COLOR="Red"]p[/COLOR], [COLOR="Red"]q[/COLOR]); fprintf (outFileOne, "%8.3f %8.3[COLOR="Red"]f[/COLOR] …

Member Avatar for isrinc
0
1K
Member Avatar for mapla

It would be easier, and probably better, to use strtol, strtoul, or even sscanf, if you ask me. Did you have a question about the code?

Member Avatar for prushik
-2
163
Member Avatar for deepin

Breaking out of a loop from a [ICODE]switch[/ICODE] is one of the few places in which a [ICODE]goto[/ICODE] does exactly what is intended without introducing more complexity. But this is typically not the solution; instead, "functionizing" the loop/switch and using a [ICODE]return[/ICODE] statement from the desired case is probably going …

Member Avatar for WaltP
0
3K
Member Avatar for zukkoor

[CODE]#define a 1.61803 /* no semicolon */[/CODE]Your function before main is missing a closing brace. Most of the errors show that you might not be aware of how to use pointers?

Member Avatar for jonsca
0
3K
Member Avatar for marirs07

[QUOTE=marirs07;1082514]What does the linker error "SEGMENT_TEXT EXCEEDS 64K"mean,is there any way to solve this.Plz Reply SOON!Thanks in advance[/QUOTE] Turbo C? Compiling a DOS app?

Member Avatar for ablitz
0
112
Member Avatar for Androggles

Typo (semicolon in place of a comma): [CODE]HRESULT CreateShortcut(/*in*/ LPCTSTR lpszFileName[COLOR="Red"][B];[/B][/COLOR] /*in*/ LPCTSTR lpszDesc, /*in*/ LPCTSTR lpszShortcutPath)[/CODE] Have you #included all necessary headers? [edit]Errors I see after minor tweaking: [QUOTE]main.cpp: In function `HRESULT CreateShortcut(const TCHAR*, const TCHAR*, const TCHAR*)': main.cpp:13: error: `CComPtr' was not declared in this scope main.cpp:13: error: …

Member Avatar for Androggles
0
1K
Member Avatar for xavier666

[QUOTE]PS - Why did they (don't know who) put conio.h in C in the first place if it was such a problem?[/QUOTE]"They" didn't. It's for a third party library, one that was meant to work with DOS. Not a windows console, mind you, but DOS. Code that uses it is …

Member Avatar for binkiwinki
-3
375
Member Avatar for jigglywiggly

Active code really doesn't belong in a header. Prefer to break it up like this: [CODE]// word.h #ifndef WORD_H #define WORD_H /* Your initial comment goes here */ #include <iostream> using std::istream; using std::ostream; #include <string> using std::string; /* Substitute for string class: does operations on words */ class Word …

Member Avatar for Agni
0
160
Member Avatar for phil750

What language's syntax is this: [iCODE]current[[COLOR="Red"]13,14[/COLOR]][/iCODE]? In C and C++, you'll need to do it the long way. [QUOTE]Process(id) (space) (quantum) (space) (priority)[/QUOTE] A sample of the actual text would be helpful as well. [CODE]current[8] = ProcessID;[/CODE] Is this backwards or something? 'Cuz ProcessID doesn't look like you've given it …

Member Avatar for phil750
0
116
Member Avatar for cwarn23

[QUOTE=Ancient Dragon;1097323]Arrays in C and C++ are always pointers.[/QUOTE] Why would you say that? Most experienced C/C++ forum posters are stuck spending way too damn much time trying to unexplain "arrays are pointers". [url]http://c-faq.com/aryptr/constptr.html[/url] [url]http://c-faq.com/aryptr/aryptrequiv.html[/url] [url]http://c-faq.com/aryptr/practdiff.html[/url]

Member Avatar for Ancient Dragon
1
205
Member Avatar for titosd

If you know what you're doing with [ICODE]*scanf[/ICODE], the its [ICODE]%s[/ICODE] directive (which is whitespace delimited) makes this dead easy. For your best results, post code when you want help with code (and please use code tags).

Member Avatar for Dave Sinkula
0
99
Member Avatar for imso
Member Avatar for Gaiety

[QUOTE=Gaiety;1095378]because int means either short or long.[/QUOTE] Or maybe it doesn't. Maybe int, short, and long all have different ranges. Gee. I guess there's a reason, then.

Member Avatar for Salem
0
154
Member Avatar for DaHandy

In order to hold 3 characters, your arrays should have size 3, not 2. [code] char day[3]; char month[3]; char year[3];[/code]

Member Avatar for DaHandy
0
100
Member Avatar for Dave Sinkula

Several methods of reversing the bits of a byte are presented here. [i]Note that not all of the methods are portable.[/i]

Member Avatar for Dave Sinkula
3
770
Member Avatar for johndoe444

The function Method3 returns a pointer to an int. Neither the pointer returned nor the int pointed to by the returned pointer is modifiable: [CODE][COLOR="Red"]const int*const[/COLOR] Method3(const int*const&)const;[/CODE] The function Method3 takes as a parameter a reference to a pointer to an int. Neither the pointer passed nor the int …

Member Avatar for Dave Sinkula
0
402
Member Avatar for daudiam

FWIW: On questions like these, I tend to search c.l.c for a while. I'm starting [URL="http://groups.google.com/groups?sourceid=groowe&ie=UTF-8&q=ptrdiff_t%20group%3Acomp.lang.c"]here[/URL]. If you care to dig while we wait (not that I know whether I'll find a good answer or not). [edit]One of the better items I've found is [URL="http://groups.google.com/group/comp.lang.c/msg/e910dd21f59a5eeb"]this[/URL]: [QUOTE][I][...][/I] ptrdiff_t was created to …

Member Avatar for Narue
0
270
Member Avatar for slim2hott

What you want to have in the brackets is another index into the key. I would assume that you want to repeat the key at the beginning after you've XOR'ed to the end of it. So you'd probably do something like this: [CODE]#include <stdio.h> char *xorcrypt(char *cipher, const char *plain, …

Member Avatar for slim2hott
0
185
Member Avatar for jezareal

[QUOTE=jezareal;1093237]Hi. im just quite new to c program and i need help on who can give me the source code.[/quote] I'm sorry to tell you you're off to a bad start. If you want source code, search. Search the web, search forums. Or make your own attempt. Find something to …

Member Avatar for Dave Sinkula
-3
258
Member Avatar for sree_ec

Do you understand the following? [CODE]#include <stdio.h> void foo(int copy) { printf("copy = %d\n", copy); copy = -5; printf("copy = %d\n", copy); } void bar(int *ptr) { printf("*ptr = %d\n", *ptr); *ptr = -5; printf("*ptr = %d\n", *ptr); } int main(void) { int value = 42; printf("value = %d\n", value); …

Member Avatar for Narue
1
343
Member Avatar for daudiam

>What is meant by "Its the result of the sizeof operation". sizeof operator requires an argument like int,char,etc. You seem to be looking at a standard definition, why not look at the whole thing? [QUOTE]6.5.3.4 The sizeof operator Constraints 1 The sizeof operator shall not be applied to an expression …

Member Avatar for Dave Sinkula
0
196
Member Avatar for ayesha91

[QUOTE=jBat;1092330]I'm just declaring a char array like a local variable i don't think we need to do :[/QUOTE] I believe you are using a nonstandard language extension, so "works!" either means "it works" or "it doesn't work". As a solution, then, it's not the greatest.

Member Avatar for Lerner
0
159
Member Avatar for Gonbe

Are you certain that the crash occurs at the getline call? I'm not on a *nix system, so I can't run your code, but that call looks okay given [URL="http://man-wiki.net/index.php/3:getline"]this[/URL] and what I see in the code. Did you discover the crash point by stepping through with a debugger? If …

Member Avatar for Dave Sinkula
0
2K
Member Avatar for _Michael_

[url]http://www.google.com/search?q=GMP[/url] for very large numbers outside of integer ranges.

Member Avatar for WaltP
0
129
Member Avatar for لولوة

Or let's say you [I]don't[/I] create an object that is itself const. [code]int main() { T t(42); display(t); return 0; }[/code] But we have this [ICODE]display()[/ICODE] function. It has no business changing anything in the object, it just displays stuff. Since it doesn't change the object, we make sure the …

Member Avatar for Dave Sinkula
0
213
Member Avatar for gerard4143

PC-lint for C/C++ (NT) Vers. 8.00u, Copyright Gimpel Software 1985-2006 main.c:7: Warning 413: [COLOR="Red"]Likely use of null pointer 'iptr' in left argument to operator 'ptr+int' [/COLOR]

Member Avatar for gerard4143
0
142
Member Avatar for iru

[QUOTE=iru;1081374]'Fred' is defined in the .c file as "void Fred(void);".[/QUOTE] That's just a prototype. The function actually needs to be defined somewhere, or else the linker will complain (as you see). A function needs to exist if it is going to be called. This non-existent function of course will not …

Member Avatar for iru
0
277
Member Avatar for lisedaton

If you want help with code, it's generally a good idea to post code. Otherwise, I trust what the compiler has told you is correct and as clear as possible.

Member Avatar for Narue
0
133
Member Avatar for Dave Sinkula

The replies, or even the replying-to, in the Code Snippets to me would work better if they were like forum posts. When replying, is there some hidden quote button? Why the different look to begin with?

Member Avatar for Ancient Dragon
1
78
Member Avatar for rgpii

[CODE]template <typename Type> void dbList<Type>::insertNode(Type v) { [COLOR="Red"]Node* tempa;[/COLOR] Node* tempb; Node* tempc; [COLOR="Red"]tempa[/COLOR]->data=v; [/CODE]Where does tempa point?

Member Avatar for Agni
0
118

The End.