|
I think the format converts it to unsigned long by default anyways. The large number is just how a negative number is expressed. It is (0xFFFFFFFF - 2600). If you want it to act as needed you must do it yourself:
_stprintf(sz, _T("%s%X"), (nOffset < 0 ? _T("-") : "", <br />
(nOffset < 0 ? -nOffset : nOffset);
J.
----------------------------
|
|
|
|
|
Thank you for the reply, but I have to make sure that the result string does not exceed 8 characters long, so the "-" cannot be added. I used PJ Arends's method and it worked perfectly. Thanks again.
|
|
|
|
|
I need this in c++ console.
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Searching where ? The command line ? Text input ? A file ? The cracks in the floor ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I want to open a file, text, and look for a specific character, ' ; '. Also I would like to see how many lines were before the actual character. Please help me in any of the above problems.
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Sounds like you are writing a C compiler...
Maxwell Chen
|
|
|
|
|
no not really, im doing a real AI program that learns tic tac toe from nothing, please help me. confused:
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Read my article on extending iostreams to write a custom stream. I'd impliment a stream that derives from fstream, and add behaviour to count newlines and stop on a ;
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
This may be of some help.
#include <stdio.h>
#include <string.h>
int main ()
{
char str[] = "This is a sample string";
char key[] = "aeiou";
char * pch;
printf ("Vowels in '%s': ",str);
pch = strpbrk (str, key);
while (pch != NULL)
{
printf ("%c " , *pch);
pch = strpbrk (pch+1,key);
}
printf ("\n");
return 0;
}
Output:
Vowels in 'This is a sample string': i i a a e i
Thank You
Bo Hunter
|
|
|
|
|
Hey, cool. A C programmer. Is there much work in C still ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
How would you go about developing an algorithm that would for
example takes a list of songs and shuffles them and uses each
song once and only once? Also what if you wanted to me aware
of the order so that you could have a previous function that
would give you the previous song in the list back to the
beginning?
Thanks,
Steve
|
|
|
|
|
This is not optimal, but it can serve your purposes:- Let
n be the number of songs to shuffle.
- Define a map of
int s to string s.
- For every song in the list:
- Generate a random number
r between 0 and n-1 , check if the r -th entry of the map is empty, repeat until you find an empty slot.
- Insert the song into the map using index
r
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your responses. I will look into Mr. Dunn's comment as well.
Steve
|
|
|
|
|
I recommend you rather follow Mr Dunn's comment, it is a much cleaner solution. Somehow I forgot about std::random_shuffle .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
I recommend you rather follow Mr Dunn's comment, it is a much cleaner solution. Somehow I forgot about std::random_shuffle.
Muchas gracias tio.
Steve
|
|
|
|
|
|
Has anybody been able to build the Boost library for MS Visual C++ 6.0. I have downloaded Boostjam and followed all the instructions on getting the library built but I don't get any *.lib files in the end, just .CMD files.
Can anybody help?
I am the handsome one in the crowd.
|
|
|
|
|
I guess you might get more helpful response at the Boost Users mailing list[^].
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have been drawing a dialog box with CDC class. How do I clear what I have drawn to the dialog box?
|
|
|
|
|
With RedrawWindow maybe?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I reposting this in the vain hope of a new reply:
How do you specify to use the deprecated fstream rather than the std::fstream ? I am encountering major proplems with this, and it seems there is no easy solution listed, and it seems that there should be.
J.
----------------------------
|
|
|
|
|
old fstream is included by (deprecated) <fstream.h> , but if you're mixing old and new C++ you sure are going to run into trouble.
Cannot you afford upgrading to std::fstream instead? If you have problems in the process, here we are to provide a little help
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am trying to include some source with STL into a project that uses lots of plain vanilla fstreams. It is not really practical to go through and change the old code because of the enormity of the task. I have tried using blank namespace to no avail, but perhaps I am doing something wrong.
J.
----------------------------
|
|
|
|
|
Could you please explain what yout "blank namespace" trick consists in?
Anyway, doesn't your program work if you include <fstream.h> ?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have used <fstream.h> but one of the alterations was in the stdafx.h file which then in turn seems to confuse the compiler and it seems to be misdirected so that it can't find the correct headers. I get a huge number of errors after that all having to do with the fstream functions. I started to change the <fstream.h> to the templated <fstream> but then discovered that this in turn would require more changes because the geniuses at C++ standards committee had changed some member functions there too.
I have had similar problems on linux GCC in which updated compilers seem to break when trying to compile code that was compiling perfectly beforehand. fstream again seems to be the class that confuses it.
J.
----------------------------
|
|
|
|