3,183 Posted Topics
Re: > Actually, this is very easily done...that is if you did some basic C-language based I guess- programming including pointers. In C, since you can use pointer arithmatic on a pointer that you have malloced initially. So, if you are to say make a pooled memory-or given a memory space … | |
Re: If you want to write standard C++, I'd strongly recommend only using an empty project. Then you don't have to deal with Microsoft's precompiled headers (stdafx.h) or any of their character width agnostic types. The _T stuff is supposed to use the correct width character type depending on whether a … | |
Re: Whether it's simple or not depends on how well you know C, but I think the following is trivial: #include <stdio.h> #include <time.h> int main(void) { struct tm d1 = {0}, d2 = {0}; d1.tm_year = 2012 - 1900; d1.tm_mon = 7; d1.tm_mday = 18; d2.tm_year = 2011 - 1900; … | |
Re: > Verifies that a legitimate 24hour notation has been input by using the assert statement Just so you understand, this is an extremely poor practice. The assert() macro should only be used for shaking out bugs because it invokes a hard stop on the process. Here you're using it for … | |
Re: > My understanding of the C language is that the same identifier cannot be reused. That's correct, but only within the same name space (not the same as a C++ namespace). There are five listed name spaces in C: 1. Label names (such as cases and goto labels). 2. Structure, … | |
Re: Type everything on one line, then press enter. scanf() is natrually designed to handle this kind of input unless you go out of your way to ensure that each number is on a separate line. But even then, after you hit enter the cursor will move to the next line. … | |
Re: The pioneering spirit appears to be dead, at least among the latest generation of programmers. | |
Re: I'm again assuming that your output is to the command prompt. And the answer is yes, but not as easily as setting a center attribute. When it comes to "formatting" in the command prompt you need to fill the line with leading spaces to put it where you want. For … | |
Re: > don't say do it by your self i could'nt understand thats why i am asking from you if i know then why i ask i don't know thats why i am asking friends plz help me...!! Please don't just post your assignment and say you don't understand, that's not … | |
![]() | Re: > A list is there in which infinite numbers(approx 1 lakh) 1 lakh is hardly infinite. Hell, I wouldn't be against bubble sorting an array of 100,000 items on modern hardware, and bubble sort is the canonical "slow" algorithm. > I know this question will be solved by using heap(min … |
Re: > zeroliken you are wrong > Its not the right answer Then what do you think is the right answer? The sequence you showed is clearly 5^n at every step. If the 5th step isn't 3125 (5^5) then either you didn't provide sufficient information about the sequence to reach the … | |
Re: strrev() isn't a standard function, so compilers aren't obligated to support it. What compiler are you using? | |
Re: How about *"A Proposal to leave the dark ages and start doing the same shit everyone else with any sense has had in place for two decades"*? ;D But seriously, something that highlights the benefits of the system would be a good idea. Like *"Streamlining the book borrowing process"*, or … | |
Re: I'm no longer hip on Turbo C stuff, but if textcolor() works in any sane manner, it should set the color to whatever you chose until the next call. So for one word: textcolor(WHITE); printf("You chose: "); fflush(stdout); textcolor(RED); printf("RED\n"); textcolor(WHITE); | |
Re: Daniweb is not a homework service. Please make an honest attempt to solve the problem yourself, then ask specific questions if you need help. | |
Re: Do you just need to read it line by line, or do you need to actually tokenize and parse the verilog language? | |
![]() | Re: It will be "nitin". `s` can't be a null pointer because it's an array. ![]() |
Re: It's generally advisable to use fgets() to retrieve a line, then parse the line in memory, possibly with sscanf(). But the needs of your program override general advice, and it looks a lot like you need to tokenize a function call for a compiler. What does the file represent, and … | |
Re: What compiler and OS are you using? What's the runtime error? | |
Re: > so what should i do to fix the problem. You should post your code so that we don't need a crystal ball to figure out where the problem is and what's causing it. Would you ask a mechanic to fix your car without actually bringing the car? > pls … | |
Re: Just for the record, when someone talks about occurrences they almost never mean combinations. As for how this works, it recursively builds a tree that breaks down the string, swaps elements, and recombines them to produce combinations. When you have an algorithm you don't understand, the best approach is to … | |
Re: Use the difference of the two numbers as the upper end of the range, then add the lower number: x = lo + rand() % (hi - lo); This assumes that lo isn't greater than hi. Also, strange things happen with negative numbers, so ideally the range would be positive. | |
Re: Nobody is going to do your homework for you, and calling it a competition isn't going to fool the vast majority of us. Please read our rules, provide proof of effort, ask some questions, and we'll help you do it. | |
Re: As a measure against spammers and scammers, we disallow sending PMs until you've posted enough, gained enough reputation, or been a member long enough to reach the rank of Community Member. The requirements aren't stringent at all (15 rep points or 5 posts + 5 days), but it ensures that … | |
Re: #include <stdio.h> #define MAX 5 void store(int a[], int i, int n); int main(void) { int a[MAX]; int i; store(a, 0, MAX); /* Test the result */ for (i = 0; i < MAX; ++i) printf("%d ", a[i]); puts(""); return 0; } void store(int a[], int i, int n) { … | |
Re: > Not in C or C++. Index values must be positive. As long as the index refers to some location in the array's boundaries, indices may be positive or negative. For example: int a[] = {1, 2, 3, 4, 5}; int *p = a + 2; printf("%d\n", p[-1]); /* Perfectly … | |
Re: You don't have a prototype for gem(), you're not passing the required arguments, getch() requires conio.h to be included, and relying in implicit int for main()'s return type is poor practice give that this feature was removed in C99. | |
Re: Are you posting code to show others, or do you have problems with that program that you need help with? If it's the latter, please ask a question. If it's the former, let me know and I'll turn this thread into a code snippet. | |
Re: While it may be all in good fun, I don't see any reason to hide the numbers or the titles. Especially given that it's public knowledge anyway, if you're willing to search through our members to figure it all out (which would be tedious and annoying). I suspect we have … | |
Re: Daniweb is not a homework service. Please provide some proof that you've attempted to write this program on your own. | |
Re: Because 999 is ultimately being broken down into 3 calls of fun(9), which when added together produce 24. The recursive tree looks like this: fun(999) | +-> fun(99) | | | +-> fun(9) | | | | | +-> return 8 | | | +->fun(9) | | | +-> return … | |
Re: > I'm not sure when to use long vs int. Use long when the value stored in the variable may exceed 16 bits. int is only guaranteed to be at least 16 bits and long is only guaranteed to be at least 32 bits. C++11 supports the long long data … | |
Re: I think you may have posted prematurely. The referenced "following" statements aren't present. | |
Re: Your copy constructor doesn't do anything meaningful, which means that precedes() will always get a garbage initialized Date object. You also forgot to increment `day_` in advance(), which means the loop in main() will run forever. I find it odd that you say only "Monday" is ever printed when the … | |
Re: > does this mean that the user needs to enter another input (may be a string or an integer or so) so that the scanf returns? It means there needs to be at least one non-whitespace character after all of the whitespace characters. When you put whitespace in the format … | |
Re: I imagine it's not printing because root is *not* NULL. Change your if statement's test to if (root != NULL) cout<<root->info; ![]() | |
![]() | Re: [This](http://comeoncodeon.wordpress.com/2009/09/17/binary-indexed-tree-bit/) was the first hit on google. ![]() |
Re: You can get more information by printing the error message with perror(): if ((fp = fopen("new.txt", "r")) == NULL) { perror("Error opening new.txt"); ... } But I notice that you have a rogue semicolon after the condition of your if statement, which means that the printf and return will *always* … | |
Re: > I want to get output which same as the input. Then use strings. Floating-point is inherently imprecise due to the limitations of the machine and gains or losses from rounding. It's unreasonable to expect the internal representation of a value to be exactly what the user typed for input, … | |
Re: In all honesty, you'd be better off looking for a job in IT and then transitioning into development. That's what I did, and the IT experience has proven invaluable as a developer. | |
Re: What compiler, OS, and IDE are you using? The simple answer is that you need to add an icon resource to your project and include that resource in the build. But that doesn't answer your question of *how* to do it. | |
Re: > Markdown is a pain. I still haven't decided yet if Markdown's finickiness is an improvement over BBCode's verbosity, but there's no argument here that both can be a pain. | |
Re: Open a file stream using fopen(), then call fprintf() instead of printf(). Alternatively, you could redirect stdin into a file, but I don't get the impression that this is what you want. | |
Re: Wow, that's a hideous abuse of the preprocessor. | |
Re: Ignoring the questionable use of goto here, you never initialize or update the value of `a`, yet that value is assigned to `j` when a number is not prime. That raises red flags. If the purpose of this algorithm is to print the primality of every number from [1,N] then … | |
Re: > cannot convert parameter 1 from 'char *' to 'LPCWSTR' LPCWSTR is a wide character type. Make sure you don't have Unicode enabled anywhere in your project or code if you don't intend to use the wide character functions. > unsafe operation: no value of type 'bool' promoted to type … | |
Re: There's no stack overflow, you're trying to dereference an uninitialized pointer. I'm not sure what to tell you at this point because you seem to completely ignore the advice of people who are trying to help you, and continually try to write code that you **obviously** lack the prerequisite knowledge … | |
Re: Daniweb isn't a free code service. Please write the code yourself and ask specific questions if you need help doing so. |
The End.