6,741 Posted Topics
Re: [QUOTE]Yes I have seen other threads like this, but they do not really satisfy my need[/QUOTE] Then please list your requirements. The threads you speak of usually result in something like this (using Windows since you mentioned WM_KEYDOWN): [code] char& raw_input(char& ch) { HANDLE h = GetStdHandle(STD_INPUT_HANDLE); DWORD old_mode, n; … | |
Re: [QUOTE]fscanf returns EOF in case of errors or if it reaches eof.[/QUOTE] Specifically, it returns EOF if an "input failure" occurs before any conversion. Otherwise it returns the number of successful conversions which may be as few as zero. "Input failure" basically means anything that isn't a matching failure for … | |
Re: I weep for the fall of higher education. | |
Re: [QUOTE=sunn shine;1662459]im new here , so i dont know how to CODE effectively.. i just copied my c++ code frm my computer, pasted it here and pressed the [code] option.. is that right or wrong?[/QUOTE] [URL="http://www.youtube.com/watch?v=6SHhxh--JT4"]Click Me[/URL]. The most important part is that your code actually have formatting. If there's … | |
Re: That expression is undefined because you're modifying b and also accessing it for purposes other than to calculate the modification between sequence points. The rule is subtle, so I won't expect you to understand it, but do keep in mind that the expression is wrong and doesn't have predictable behavior. … | |
Re: [QUOTE]but next to it the black light indicating negative rep.[/QUOTE] Negative rep is colored red, not gray. Gray boxes are used for the Community Center (where rep points don't count), and users who have too little rep power to affect you. | |
Re: [QUOTE]is there a way to do 128 bit comparison in one instruction with SSE 4.2a?[/QUOTE] No. [QUOTE]If not, what would be the fastest way to compare with two steps of 64bit comparisions?[/QUOTE] Compare the high quadword, then the low quadword if the high quadwords are equal. | |
Re: By 'without using system("color hex")' do you still mean "works on all systems magically"? | |
Re: The best alternative is not to clear the screen. Most of the time when I see things like [iCODE]system("cls")[/iCODE] or [iCODE]clrscr()[/iCODE], there's no legitimate reason for clearing the screen. However, since you're using Windows you might consider the Win32 API as a reasonably portable (on Windows) solution. If you're dead … | |
Re: [QUOTE]Thank you... (1) so it is like that, we can not read float values directly??? and can u please tell me about these two lines. extern void float conetor(); #pragma extref floatconnector it is for reading float value directly and even though i was getting error. [/QUOTE] [url]http://c-faq.com/fp/fpnotlinked.html[/url] [QUOTE](2) and … | |
Re: Not enough information. Since you're declaring TotalCS, I would assume that you have an error where TotalCS is declared in a scope that isn't visible at the time of that expression. However, I can't say for sure with so little code. Trim your program down to bare bones (without removing … | |
Re: The function needs to be declared before its first use either with a prototype or by placing the definition prior to main(). | |
Re: You neglected to ask a question. | |
Re: [QUOTE]What is the meaning of using dynamic_cast without any error handling?[/QUOTE] It means the author was confident that the cast would succeed. That's somewhat foolish in my opinion. Except for the most basic of code, you can't easily make such a guarantee. [QUOTE]I find out one thing, even I didn't … | |
Re: You don't want to do it that way. Use an array instead, where you would otherwise be tempted for name1, name2, name3, ..., nameN variables: [code] int (*tickets)[6] = malloc(bet * sizeof *tickets); for (int x = 0; x < bet; x++) { printf("Enter the 6 numbers ( 1 - … | |
Re: [QUOTE=stereomatching;1660751][code] void testRR(std::string &A); [/code] [code] void testRR(std::string &&A); [/code] Which one is better? [/QUOTE] You should prefer lvalue references to non-const for things you want to modify and lvalue references to const for things you can't or don't want to modify (rvalues are neatly handled here). In other words, … | |
Re: [QUOTE=limaulime;1660935]OK, I think I get it. You don't have to have "case" for each character, but you can use logical operand because based on ASCII each character has it's own number. Example: if you want to check for lower case characters [CODE]if ((ch>='a') && (ch<='z')) { cout <<"lower case " … | |
Re: The extra 00 is the 0 you tacked onto the end of [ICODE]source[/ICODE]. You should initialize ecx to SIZEOF source - 1, since that 0 is a sentinel rather than a value character. | |
Re: "void mainers are DOOMed" "Geeks Lounge Junkie" "Banned" "Programming Forums Survivor" "What is Area 51?" "Superduper Mod" | |
Re: [QUOTE]Your second comment is that C is still after many years the main programming language[/QUOTE] Being "honored" (or even "widely used") and being the "main programming language" are two completely different things. [QUOTE]So i tell you what, THINK about your replies before you post them, thanks a lot dear![/QUOTE] Follow … | |
Re: You're not properly resetting between persistence iterations. For example, x doesn't get reset to 1. | |
Re: [QUOTE]"Let us c" is the best book....[/QUOTE] Wrong. | |
Re: Please post a complete program that exhibits the problem. If you think the current complete program is too large, remove stuff (without losing the error) until it's small enough to post. | |
Re: [QUOTE=syaminismail;1660437]please help me friends....huhuhuhu... im so need this answer now for present tomorrow....huhuhu[/QUOTE] This thread is now closed as it's in violation of our homework rule. | |
Re: There's a newline left in the stream the second time you call start(). Do some research on this, it's a classic and [u]very[/u] common problem. | |
Re: [QUOTE]what do you mean by K?[/QUOTE] He means that the iostream library takes up more space in the executable than the stdio library after compilation. It's not an unreasonable concern, but shouldn't be the [I]only[/I] concern when choosing between iostream and stdio. | |
Re: [QUOTE]i counted variables,consts,commas,references everything seems to be ok...[/QUOTE] I see a missing const in your definition, but I think a bigger issue is that you're passing way too many parameters. If you find yourself passing more than three, there might be something wrong with your design. | |
Re: Ignoring the myriad issues your code has that aren't likely to be your actual problem, this line is wrong: [code] scanf("%d",jamia[i].salary); // Wrong [/code] Since [ICODE]jamia[i].salary[/ICODE] is not already a pointer, you need to prepend it with the address-of operator: [code] scanf("%d", &jamia[i].salary); // Correct [/code] | |
Re: The compiler is right, LINE_MAX doesn't exist unless it's a library extension. I'd suggest the standard BUFSIZ, but that still won't work either because your code is severely broken. You're working with uninitialized pointers. | |
I'm digging this change. It's small, but solved threads are much more visible now. :) | |
Re: There are two parts for the field width using %f. The first part is the total width including radix and precision. The second part is the width of the precision. A leading 0 will change the padding from whitespace to zeros: [code] printf("%020.3f\n", 123.456); /* Line 8 */ printf("%020.9f\n", 123.456); … | |
Re: [QUOTE]I can't catch exception on windows services.[/QUOTE] Where is the exception coming from? That can be a significant reason why you aren't seeing it handled. For example, if your service creates a thread which then throws an unhandled exception, it won't be caught by the unhandled exception handler. [QUOTE]I mustn't … | |
Re: Basically all you need the time.h library for is slowing things down enough to produce the effect of animation: [code] #include <iostream> #include <ctime> void pause_execution(double seconds) { std::time_t start = std::time(0); while (std::difftime(std::time(0), start) < seconds) ; } int main() { std::cout << "Paused" << std::flush; for (int i … | |
Re: Apparently you're in the same class as another Daniweb member. Might I suggest searching for that thread? It has the same title and hasn't left page 1 yet (lazy much?). | |
Re: There isn't a single compiler that supports all of C++0x at this point. I believe GCC (starting at 4.6 or 4.7) is the closest though, if you want to play with C++0x I'd go with GCC. | |
Re: Presumably dword_8EF798 isn't a pointer, but an actual dword object. To dereference it you first need to take the address. Without the address-of operator, you'd be dereferencing whatever integer value is stored in the object, and probably get an access violation because it's not a valid address reference. | |
Re: [QUOTE]What is the use of (void *)?[/QUOTE] The %p specifier expects a pointer to void (the generic pointer type in C). In cases where the address you want to print isn't already a pointer to void, a cast is used to make it so. [QUOTE]And why are the results in … | |
Re: [QUOTE]i really need a GOOD socket tutorial[/QUOTE] The #1 recommended tutorial is [URL="http://beej.us/guide/bgnet/"]Beej's guide[/URL]. | |
Re: [QUOTE]What is a good new compiler (C++ and D would be nice) for Linux?[/QUOTE] GCC is generally recommended for C++. [QUOTE]PS Is the system() function universal as in it will do the same thinge in Linux Windows and OSX[/QUOTE] It's universal in that you can use it, but the argument … | |
Re: [QUOTE]Its a long time doubt and no one really gives a clear and confident answer to this one.[/QUOTE] Because there's not a clear answer. Different compilers are free to do it in different ways provided the effect is the same. However, typically local variables will all be allocated to the … | |
Re: Your [ICODE]b[/ICODE] pointer is completely uninitialized. | |
Re: [QUOTE]if you check the ASCII table, '\0' is called NUL and has been named so because it has no resemblance with the NULL pointer.[/QUOTE] This is a sticky area. Technically, '\0' has a numeric value of 0, which means it's valid as a null pointer constant, and thus equivalent to … | |
Re: The usual method is seeding rand() with the current time: [code] #include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { int i; srand((unsigned)time(NULL)); for (i = 0; i < 10; i++) printf("%3d", rand() % 100); putchar('\n'); return 0; } [/code] | |
Re: We're not your personal computing reference. Go do some research instead of bothering people with questions that could be easily answered by searching the web or reading manuals. | |
Re: [QUOTE]I don't understand why you have done b++[/QUOTE] Negative indices are syntactically allowed, but the index also has to be valid. Arrays in C are 0-based, which means if you want to index them with negative values, you need to shift the "beginning" of the array forward enough to make … | |
Re: malloc() and free() are declared in <stdlib.h>, you failed to include that header. | |
Re: [QUOTE]Use fgets instead , since scanf is not considered safe.[/QUOTE] scanf() is perfectly safe when used correctly. The problem is things like %s without a field width where the programmer has no clue that it's a buffer overflow waiting to happen. If scanf() is so unsafe, then why is the … | |
Re: Your interview has no unique questions, try searching the forum for previous people asking the same thing. After a few dozen times, it gets old for those of us being interviewed. | |
Re: [QUOTE]Other than academic, there is no good reason to translate it.[/QUOTE] Unless you're writing a C compiler. It's not unusual to have intermediate assembly language output which is subsequently fed to an existing assembler that produces the final object code. |
The End.