2,384 Posted Topics
Re: [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] | |
Re: [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 … | |
Re: 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 … | |
Re: [ICODE]-pedantic[/ICODE] [QUOTE]main.cpp:4: error: ISO C++ forbids variable-size array `arr'[/QUOTE] | |
Re: [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]? | |
Re: [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. | |
Re: 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 … | |
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 … | |
Re: Don't paraphrase code, just copy and paste (and thanks for using code tags). | |
Re: [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 … | |
Re: [url]http://www.compilers.net/Dir/Compilers/CCpp.htm[/url] [url]http://www.compilers.net/Dir/Free/Compilers/CCpp.htm[/url] | |
Re: 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) ) … | |
Re: 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. | |
Re: [url]http://eternallyconfuzzled.com/tuts/languages/jsw_tut_pointers.aspx#reftptr[/url] | |
Re: [url]http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.6[/url] | |
Re: Multiply by 100. (Isn't that an elementary school question?) | |
Re: [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 … ![]() | |
Re: [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 … | |
Re: [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.) | |
Re: [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 … | |
Re: 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] … | |
Re: 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? | |
Re: 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 … | |
Re: [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? | |
Re: [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? | |
Re: 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: … | |
Re: [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 … | |
Re: 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 … | |
Re: 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 … | |
Re: [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] | |
Re: 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). | |
Re: [URL="http://www.daniweb.com/code/snippet216402.html"]FWIW[/URL] | |
Re: [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. | |
Re: 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] | |
Several methods of reversing the bits of a byte are presented here. [i]Note that not all of the methods are portable.[/i] | |
Re: 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 … | |
Re: 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 … | |
Re: 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, … | |
Re: [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 … | |
Re: 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); … | |
Re: >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 … | |
Re: [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. | |
Re: 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 … | |
![]() | Re: [url]http://www.google.com/search?q=GMP[/url] for very large numbers outside of integer ranges. |
Re: 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 … | |
Re: 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] | |
Re: [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 … | |
Re: 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. | |
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? | |
Re: [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? |
The End.