Well, let me back up then. I might not be understanding how the flags work. For instance, I was thinking this code would print 123 in hex format:
#include <iostream>
#include <iomanip>
...
Type: Posts; User: miclus
Well, let me back up then. I might not be understanding how the flags work. For instance, I was thinking this code would print 123 in hex format:
#include <iostream>
#include <iomanip>
...
Thanks. I forgot to mention that I'll be printing unsigned long values, so I can't use a string of characters.
Thanks for replying. I can get it working like that, but I can't get it to set the stream like that and pass it off to a function.
I need to pass the std::cout to a function so that numbers print in hex and uppercase and 8 digits are printed with 0 fill. I got it to print in hex and uppercase, but I can't figure out the 0 fill....
Is it wrong to call exit(1) when a failed memory request happens since there may be dynamically allocated memory that exists elsewhere in the program that won't get freed?
Thanks for the replies. After testing, I see that not freeing the variable creates a memory leak. I call the test function in a loop and it eventually gives me a memory error, I suspect since I'm...
Also, if I get rid of this line only:
dirPtr = (char *)malloc(5);
It seems to work out fine.
Interesting. I have read other places that a copy is made so it's ok. I'm only an average programmer. So, I always clean up any dynamically allocated memory I create. So, I guess this is ok not...
Hi, someone suggested I post this here. I'm writing a shell and my environment variables seem to get corrupted for strange reasons. Here is one example of code. The correlation seems to be with...
Hmm, can you try this Nessarose?
int main()
{
char *dirPtr;
char *path;
path = (char *)malloc(12);
Hi, I'm creating a shell and when I call the getcwd() function, it makes any environment variables I defined go away. Here is an example:
int main()
{
char dir[500];
...
Hi, I have this array of pointers:
char *test[50];
I want to be able to pass it to a function without the function being able to change anything in the array. Any ideas?
Hi, thanks for the help. I think I found the problem. I had
args[argnum] = new char[sizeof(superbuffer) + 1];
I think I meant strlen(superbuffer).
Hi, can anyone explain why this crashes at the delete part?
char *args[1000];
args[0] = new char[10];
delete [] args[0];
Thanks.
Works great. Thanks.
Hi, I was wondering if there is a simple way to get the current date in C?
Wow, thanks, it brought my file down to 43kb! Thanks!
No, but I did now and it fixed it. But, not the other error:
error: `chdir' undeclared (first use this function)
Thanks for the reply. I get 2 errors though, trying to compile with this. They are both similar so I'll only list one:
recorder.cpp:107: error: `mkdir' undeclared (first use this function)
It...
Hi, I am looking for a compiler that creates a dos executable and can make it real small. I have a bit of code I wrote that is about 5kb and when I compile it in Visual C++ I get an exe file size of...
Yeah, I mean the built-in keyword types where you put "int" or "char" for instance. Thanks for the replies.
Hi, I was wondering if the atomic types in C++ have constructors and destructors?