if(root==NULL)
has no meaning at all...
It has meaning, it's just a pointless meaning. ;)
if(root==NULL)
has no meaning at all...
It has meaning, it's just a pointless meaning. ;)
i stopped using void main() my dear friend
I know. I also know that you only stopped using it like yesterday. Further, I know that you've been told many, many, many times that void main is wrong and why, yet you stubbornly continuted to use it since you joined in April.
Kudos for no longer using void main, but such a trivial thing was a long and arduous battle. I'm inclined to believe that you'll be equally difficult to teach for everything else, and it tires me out just thinking of the long threads trying to convince you in vain to do things the right way or help you see the mistakes that you habitually make.
please shoot out where i lack.or tell me in which topic i should be strong
I already told you: start over from hello world. Take your time with everything, including the little details. You've tried to progress too quickly and ended up in territory where your knowledge/experience is woefully inadequate.
The fact that you only recently learned how to consistently apply the address-of operator to non-pointer arguments for scanf() is evidence of your current level, yet you still try to do relatively complex things (eg. a pointer to a pointer to a structure).
Given how long it took you to finally stop using void main, despite being hounded by at least one person in every thread, I'm disinclined to humor you as you learn C in the least efficient way possible: dumb luck.
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 and experience for.
You can't take shortcuts in this. Learn it step by step from the beginning, or you'll end up right where you are now: unable to write anything without asking for help on the basics that you neglected.
I think I'll just write you off as a lost cause and ignore any future questions, because it strikes me as a complete waste of my time to help someone who refuses to learn.
i use Dev- C++ and was thinking to use CreateDirectory() and CopyFile() but failed!!
I'm not surprised. It's not just a matter of copying the executable and such, you also need all of the dependent libraries that may not be on the target system. That's why I recommend that you use Windows Installer, because that's the correct way to create an installation package on Windows.
Daniweb isn't a free code service. Please write the code yourself and ask specific questions if you need help doing so.
I imagine it's not printing because root is not NULL. Change your if statement's test to
if (root != NULL) cout<<root->info;
Windows has its own installer program that consumes MSI/MSP files, so you need to create one of those files for your program. I think the easiest way to go about that would be a tool like Inno Setup, but you can also use a setup project in, for example, Visual Studio (not the Express versions though).
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 string, you can think of it as a specifier saying "read and discard all contiguous whitespace". If a newline is the last character then scanf() doesn't have any way of knowing it's the last and will wait for you to give it more.
Context, it's important.
I think this is caused by removing the new posts, but, if this is so, isn't it possible to also update the 'last posted' date (if that's how it's stored) so that it won't come up any longer as one of the last updated threads?
It's possible, but not practical. The last posted date isn't tied to the actual last post in the database, it's a denormalized field stored directly at the article level. As such, when deleting the last post from a thread, we would also need to do a query for all of the other posts in the thread, then take the timestamp of the new last post and overwrite the field in the article with that value.
Another alternative would be to redesign how the timestamp is handled and query for it rather than store it directly as redundant data, but that too involves touching the database more than we'd like.
In terms of efficiency, adding that feature would be a kick in the balls, which is why we haven't done it yet.
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.
Is it possible to add a new category? Yes or No?
If YES we dicussed about it or NO I will click Solved and more on.
Yes, it's possible. Either Dani or I would have to do it on the code/database side, but it's certainly possible. Whether adding categories when Daniweb is already fragmented (some would say overly fragmented) is another matter.
In the past we've gone with the petition route. If you can find enough people to petition for the addition of a new forum or category, we can consider it. The problem is that we don't want a lot of forums with low activity, so there needs to be sufficient demand before the addition can be justified.
Another thing to consider is that the tagging system is the intended future. With the design of the new system we were writing it with an eye toward making tags more of a key player (somewhat similar to Stack Overflow) than the current forum hierarchy.
This may help. You can find details about dynamic memory for arrays near the bottom, but the rest is useful information about pointers too. :)
Please don't put words in my mouth meaning qoute what I post not make up something!
To be fair, your posts suggest a non-native English speaker and I've found them slightly difficult to decipher. It's not unreasonable to see misunderstanding your posts when not everyone speaks English at the same level or with the same background, so a little tolerance couldn't hurt.
In other words, please don't be so quick to take offense.
I figured it was something along those lines. ;)
factorial(x--,y*z,z++);
You're passing the current value of x to factorial(), recursion never stops and you experience a stack overflow.
If none of the sub forums are quite right for your question, you can post to the category (ie. Databases) and tag the thread accordingly.
Yes, there's certainly a way. What OS are you targeting?
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, especially given that printf() does its own rounding when converting that value back to a string. In this specific case you can normalize the input and output by forcing a precision to the input:
printf("%.2f\n", n);
But that doesn't help if the input changes to use 3 characters past the radix, you'd see the same problem in reverse.
Dude...start back at the hello world program, because you very clearly aren't getting it. You need to take a few steps back and start learning the basics again.
Semicolon. And you've been asked before to state what the error is. If you continue to post vague requests for help, I'll stop trying to help you.
I am wondering if there is a way to include subscripts or superscripts in Daniweb?
Not presently. When we were using vBulletin as the back end we allowed TeX formatting, but it was very much unused.
I tried to use HTML code (<sub> and <sup>), but that didn't work.
Yup, straight HTML isn't allowed in our editor for various good reasons. ;)
when the line above is not wrapped in code tags, the '*' sign is removed and the characters are pushed together.
Yes, the * character has special meaning for Markdown, our formatting language. You can escape them with a backslash to disable parsing as a bold or italic starter character: \*
But sir according to me string literals can be modified
According to you? How does your authority override the official language standard? I recognize that you might use a compiler that doesn't store string literals in read only memory, but that doesn't make attempts to modify them any less wrong.
Freeing a NULL pointer will cause the program to crash.
That's incorrect. Calling free() on a null pointer is guaranteed to be a no-op.
If you can't think of a program with all of those constructs, maybe you shouldn't be using them all at once yet? ;)
Perhaps someone can describe this better!
C++ performs name mangling to enable the overloading feature. If you declared the entities with C linkage (by compiling them as C) and tried to link with the same entities that have C++ linkage (by compiling them as C++), there won't be a match due to mangling. So while the names would be declared, and appear to be defined in the source code, they wouldn't actually be defined.
What do you know about binary coded decimal representation? That appears to be what the function's intended purpose is, which is a bigger issue than the type of pBcdBin
.
But the type of pBcdBin
is a pointer to zero or more bytes (that's what uin8_t represents here), where neother the pointer itself nor the bytes may be changed, they're both immutable. Technically you could simplify the function signature like so:
short BcdBin(unsigned char *pBcdBin);
This takes advantage of the fact that short int
is at least 16 bits and unsigned char
is at least 8 bits. The const qualifiers probably aren't necessary, but they make your life easier by enforcing immutability inside the function (ie. stop you from changing them accidentally).
So how can I code a program such that the program works in the background ?
By reading my previous post: write a Windows service. Once again, I'm assuming that you're using a Windows based operating system, given the nature of the original question.
I think the errors can be summarized thusly: an array is not a pointer and a string literal may not be modified.
Because I couldn't install netbeans at home so I couldn't try.
So NetBeans is the only C++ implementation? I see you tried sooo hard. :P
This is obsolete and its use is frowned upon.
So are TSRs. If you're not into obsolete stuff, learn to write a Windows service (assuming Windows as the natural progression because you're talking about DOS).
What ever happened to reading the manual?
"Better" is a meaningless word without any context. Are you asking this question out of general curiosity or because you want to use one of those frameworks for your next project? If it's the latter, what are the needs of the project?
If it's the former then I can only say that neither one is better than the other, and which one is more suited for use in a specific project depends on the needs of that project.
but when i asked you the question abonu changing the constant through the pointer, then you said that is undefined.
Undefined means the C standard places no restrictions on behavior. This is obviously quite different from disallowed, where the standard says clearly that you aren't allowed to do something. The former means anything could happen and you need not be warned in any way, while the latter will result in a diagnostic message.
So this means i can't do that thing as it is undefined totally. So it's not correct to do that.
It's not correct, but you can still do it.
int a=10;
is it compile time constant ? how ?
10
is a compile time constant, a
is not.
What is the value of EOF in c...?
The value of the macro EOF is completely irrelevant because it's an internal standard library flag that has no meaning to either you or the outside world. Though nitin1 is correct that it's usually defined as something like -1.
Undefined reference means you've declared a name but not provided a definition anywhere. This usually happens when using a library's header without linking to the library.
Not really. See function Sort() in the code below
I stand corrected. Bubblesort is still painfully inefficient though, and even more so with linked lists due to the excessive chasing of pointers. I'll stand by my original recommendation that a streaming friendly algorithm is far better suited to sorting a linked list than the usual suspects in array sorting.
Of course, a better general solution is to modify the insertion algorithm to keep the list sorted. That way a separate (inefficient) sorting step is unnecessary and the time needed to sort the list is amortized over all of the insertion operations.
If the length of your list is large enough that a faster sort is warranted, then a linked list is the wrong choice of data structure. But I'll mention two things:
Bubble sort is a bitch with linked lists. Insertion sort is much easier to implement.
Following that line of thought, any algorithm that can run with streamed data is well suited to linked lists, so my first suggestion of a faster sort would be merge sort.
You can say that only if the compiler documents what it does. For example, some compilers support flush(stdin), but they document that support very clearly even though it's technically undefined.
It's better to simply say that the code is undefined, and thus wrong. Period.
Constant means it cannot be changed, but you've already learned how to change a const qualified value through a pointer, right?
As pertains to this issue, compile time constant basically means that the constant can be used as the size of an array or as a case label in a switch statement. If you can't do either of those two things, it's not a compile time constant.
As far as goes, it's unnecessary to micromanage like that. However, I think that given the awkwardness of using iterators here, subscripting is cleaner anyway. Just make sure to check boundaries of both vectors.
in this, do u mean b is a compile time constant and a is not ?
It is not a compile time constant.
but sir, what const has created the difference ?
The const keyword gives the compiler the chance to warn you if you accidentally try to modify the value of a variable that shouldn't be modified. It's a convenience to you, the programmer, in writing robust code.
I see that you're confused, so for now just remember that const isn't really constant, it's just read-only.
scanf("%d",n);
Apparently you still don't understand how scanf() works. Allow me to elaborate a bit. Every argument in C is passed by value, which means that a copy of the value of an argument is made and assigned to a temporary variable represented by the corresponding function parameter. So this:
void foo(int arg)
{
arg += 10;
}
int main(void)
{
int x = 0;
foo(arg);
printf("%d\n", x);
return 0;
}
Will print 0 because only the copy of x is incremented. You can think of it something like this functionally equivalent code, where the problem is far more obvious:
int main(void)
{
int x = 0;
{
int arg = x;
arg += 10;
}
printf("%d\n", x);
return 0;
}
This totally goes against what scanf() is designed to do: read values from input and assign them to variables. So how does scanf() work? Well, you can simulate pass by reference by passing the address of a variable. This creates a pointer to the object which can then be dereferenced, and the original object can be modified:
void foo(int *arg)
{
*arg += 10;
}
int main(void)
{
int x = 0;
arg(&x);
printf("%d\n", x);
return 0;
}
Now the output will be 10 because the original object is being incremended instead of a copy. The address is still passed by value, but the object stored at that address is what you really want.
This is how scanf() is able to …
Does it still show as 1 when you empty both your outbox and inbox? That should reset the count as well as remove any orphaned messages.
then why does scanf returns 1 in following case if we give a floating point variable as input..
Because scanf() reads until the first invalid character, and if there were valid characters before that such that a conversion can be performed the the conversion will succeed. The first part of a floating-point value up to the radix is a valid integer.
It's undefined because a
is being modified twice between sequence points. General best practice is to modify a variable at most one time in the statement, or even break down the statement entirely so that it always does exactly what you meant. For example, the following is much more clear as to what I wanted to happen:
int a = 10;
int b = a + (a + 1);
a += 2;
What is the reason behind it...
If you lie to printf(), you get what you deserve. When you tell printf() to expect an int, it treats whatever you pass like an int. When you tell printf() to expect a float, it treats whatever you pass like a float. If whatever you pass doesn't have a compatible byte representation, don't be surprised when you get garbage.
At this point I'll just say that there's a difference, but it's not important that you understand it yet. Understanding nuances of the C grammar isn't necessary to write code in C.