Hammer:
I'll be sure to change it if you can suggest a way to deal with the problems that would be safer than just trusting the user to not be stupid and call free_mem in the right order. ;)
...
Type: Posts; User: Dr. Bebop
Hammer:
I'll be sure to change it if you can suggest a way to deal with the problems that would be safer than just trusting the user to not be stupid and call free_mem in the right order. ;)
...
Cool, is the source available somewhere so I can see how you did things?
You wouldn't get 3, rand()%3 gives you a range between 0 and 2 but not including 3, add one to that and you get the range 1 to 3.
int quest;
char int_holder[10];
printf("Are you sure you wish to exit the Menu?\n");
printf("Press 1) to return to Options or 2) to exit the Menu: ");
quest = atoi( fgets( int_holder, 10, stdin...
Enmeduranki:
I'd expect that you wouldn't get what you wanted, explained below.
moi:
I thought about it, but picked the one I thought would be easier to write without terrible bugs.
Hammer:...
That's pretty fun, did you write it?
That's like saying "If you walked past a homosexul person one day how would you feel?". It's pointless. You should ask what you mean instead of dancing around it, "Do homosexual people make you...
Okay, here's a custom memory handler I wrote for strings so that I won't have to make a bunch of calls to malloc. I probably won't use it, but it's good practice and might come in handy sometime. The...
We feel there should be no teachers because teachers are usually the ones who know jack and can't get a real job programming, so they teach. There're exceptions, just like everything, but judging...
If you're going to use goto, at least jump forward in the code instead of backward. If you jump backward it makes the program harder to follow.
Same as above, ifyou're writing pure C then use malloc/free, if you're writing C++ then use new/delete.
I do. :p Even for 1 line programs I still want it to be right, if using a big sophisticated(sp.) text editor helps me do that then I'll use it. It's better to take the time to be right than to suffer...
Read usenet's comp.lang.c++ and alt.comp.lang.learn.c-c++. Those are the best places to get good information on C++, everywhere else you're not sure about the quality.
That's kind of dumb. Why use something like notepad when you can get much better text editors for free? You lose a lot of productivity when you have to do everything by hand that good editors do for...
From what I've seen all of the learn online classes suck. Just get a bunch of good books on the subject and have at it. That's how I learned.
The overhead is barely noticeable with a profiler, much less in a running program. Allocating memory takes time no matter how it works, so use malloc/free with C and new/delete with C++.
*(ptr + i)
and
ptr[i]
are both the same, but scanf takes a pointer, so if you used the array indexing you would have to use &ptr[i] and if you used pointer notation, which is stupid since array...
I don't think this should work anyway, data() returns an array with each character in the string an element in the array but the last element isn't a null character. c_str() returns the same as...
Converting binary to decimal is easy if the binary number is a string. Just do something like this.
#include <stdio.h>
#include <string.h>
void revstr( char *str )
{
char...
What's so hard about copy/paste and then using your compiler's hot key for formatting? In VC++ 6.0 just select the code you want to format and hit ALT+F8 and this
#include <iostream>
#include...
I get server errors most of the time and it's slow whenever I don't get errors.
The big time problem was in this line.
*at++ = *(at + 1);
It's undefined behavior because it changes at more than once in the same expression. It worked fine for me too, but that doesn't mean...
Ignore the first two functions I gave you, they're both big time wrong. This one's right.
void remchr( char *string, const char item )
{
char *at;
while( (at = strchr(...
Here's another that removes all occurances of the item instead of just the first one. :)
void remove_char( char *string, const char item )
{
char *at;
while( (at =...
Pretty easy.
#include <stdio.h>
#include <string.h>
void remove_char( char *string, const char item )
{
char *at = strchr( string, item );