|
You could only mean two things.
1. Conver the number 23 to hex.
2. Take ascii value of every character, which is again a number and convert it to hex.
You mean something other than these? If yes, you are wrong.
|
|
|
|
|
Why don't you store it into an integer instead of a char ?
|
|
|
|
|
lune12 wrote: I have tried:
char* str = "23";
char c;
sscanf(str, "%x", &c);
but the char c is 4 bytes in memory and this is not safe!!!
That's because %x indicates you want to read an integer. Read it into an integer, bounds check it if you want, then assign it to the character.
If you want to ensure you only read 2 hex characters from the input, use a width specification, like this:
sscanf(str, "%2x", &int_value);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
you may use
char * str = "23";
char * endptr;
char c = (char) strtol(str, &endptr, 16);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
typedef unsigned char byte;
typedef wchar_t charw;
typedef const charw ccharw;
ccharw *CharHexL (L"0123456789abcdef");
byte HexToByte( charw C )
{
C = towlower(C);
if( C >= CharHexL[ 0] && C <= CharHexL[ 9] ) return( byte(C-CharHexL[ 0]) );
if( C >= CharHexL[10] && C <= CharHexL[15] ) return( byte(C-CharHexL[10]) + 10 );
return(0);
}
inline byte HexToByte( charw C1, charw C2 )
{
return( (HexToByte(C1)<<4) + HexToByte(C2) );
}
If the string has an odd number of characters pass the first char to HexToByte(C) to get the values for the first byte. Walk the rest of the string two characters at a time using HexToByte(C1, C2) to convert the pairs to bytes.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
I want to cut the specified part of the wmv file using directshow editing services.I am able to cut the file using WMASFWriter.
But my problem is that WMASFWriter encode the video and gives the
bad quailty of video. so my question is that which filter is used so that I get the best quailty and do not encode the video.
|
|
|
|
|
hi,
can anyone tell me how to construct different string tables to be used for different languages and switching the language at start of program using resource dlls.
thanks
Varun Bhatt
|
|
|
|
|
|
Imagine an application that will have two documents. Eg : Doc1.txt & Doc2.txt. I need to view them both at the same time in a single window separated by a splitter. How should I design the application?
Some points to be considered.
1. There'll never be any need for another document Doc3.
Can I go for any static design that has only 2 docs?
2. I should have two independent "open file" menu item in the file menu to open Doc1 & another for Doc2.
Don't have any clue what's it all about. I just came out of SDI stuff. Now it's MDI's turn. Can someone through some light on sequence of steps that's need to achieve this requirement?
Thanks.
|
|
|
|
|
Leave it as an SDI app.
Have a 'composite document' type that represents the two documents as a single document (as far as MFC is concerned, it's a single document).
Have a single File->Open command that ensures two documents are opened to make a valid composite (the composite needs two documents, remember) but (if you want) have a UI that allows the user to open a document to replace one of the documents in the composite.
This way, you are retaining the single document<->view relationship that an MFC SDI app is built upon.
And yes, I've done this, for a tool I wrote that could either plot a file of data, or plot two files of data so that you got variables of the same name plotted on the same graph.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The idea sounds very cool. Thanks a lot.
Also, rather than having a single File->Open command, what if I have two separate File-Opens and manage the composite document with global flags? I can open a document through "open 1st doc" & then signal the flag as "Opened through 1st file" similarly for 2nd doc. And once the 2nd doc is loaded, the composite doc is built. This way the user will be allowed to view just 1 doc or view both. Sounds feasible? Or something's fundamentally wrong with his idea?
|
|
|
|
|
grassrootkit wrote: manage the composite document with global flags
The word 'global' always rings alarm bells If they're part of the document class, that's probably better.
grassrootkit wrote: I can open a document through "open 1st doc" & then signal the flag as "Opened through 1st file" similarly for 2nd doc. And once the 2nd doc is loaded, the composite doc is built. This way the user will be allowed to view just 1 doc or view both. Sounds feasible?
Probably - I had a single document for both the 'single file' and 'two files' cases. The document knew what sort of document it was (one or two files), and managed things appropriately.
It all depends what the requirements are really.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: The word 'global' always rings alarm bells
lol yes that would. Actually I planned to bring it in into the design. But to quickly explain you about what I thought I meant them as global. Anyway thanks a lot.. let me get into the lab .
|
|
|
|
|
I want to remove the character '=' and substring "%%&&**" from an input string s. The code below work fine, but if there are multiple substring, the code will only remove the substring once.
#include <stdio.h>
#include <string.h>
char *Mystrcpy1(char *s, const char *cs);
void func1(char *src, char *sub);
int main(void)
{
char s[32], *substr = "cc";
Mystrcpy1(s,"aabbccdd");
printf("From the string: \"%s\"\n",s);
printf("We will attempt to remove substring \"%s\"\n",substr);
func1(s,substr);
printf("Using function Mystrcpy1. The result: \"%s\"\n\n",s);
return 0;
}
char *Mystrcpy1(char *s, const char *cs)
{ /* Copy from beginning of string cs to the end */
char *s1;
const char *cs1;
for(s1 = s,cs1 = cs; '\0' != (*s1 = *cs1); s1++,cs1++) ;
return s;
}
void func1(char *src, char *sub)
{ /* Using function Mystrcpy1 */
char *p;
if ((p=strstr(src,sub)) != NULL)
Mystrcpy1(p,p+strlen(sub));
return;
}
|
|
|
|
|
nyc_680 wrote: The code below work fine, but if there are multiple substring, the code will only remove the substring once.
Repeating the process (until there is no match found) will help you.
- ns ami -
|
|
|
|
|
where should I put the repeting function at?
|
|
|
|
|
void func1(char *src, char *sub)
{ /* Using function Mystrcpy1 */
char *p;
if ((p=strstr(src,sub)) != NULL)
Mystrcpy1(p,p+strlen(sub));
return;
}
instate of this use
while((p=strstr(src,sub)) != NULL)
Mystrcpy1(p,p+strlen(sub));
|
|
|
|
|
Hi i am creating a SAFEARRAY of User define datatype i.e a structure which i described in my .idl file .
Now while creating a SAFEARRAY i have done this ..
IRecordInfo *pRecInfo = NULL;
//CIHPCRInjectorBarcodeData - is my structure
const GUID UUID_CIHPCRInjectorBarcodeDataStruct = __uuidof(CIHPCRInjectorBarcodeData);
shr = ::GetRecordInfoFromGuids (LIBID_HPCRInjectorSetupGTIS45Lib ,
1,0,0 ,UUID_CIHPCRInjectorBarcodeDataStruct ,
&pRecInfo );
SAFEARRAYBOUND rgsBound[1]; //This is one dimensional array.
long *pData;
long lValue , lIndex ;
rgsBound[0].lLbound = 0;
rgsBound[0].cElements = 8 ;
//Now Create SAFEARRAY
SAFEARRAY *psa = 0;
psa = ::SafeArrayCreateEx (VT_RECORD ,1,rgsBound,pRecInfo);
while debugging i found that elements are not getting initiallized ..
Please help
|
|
|
|
|
pandit84 wrote: while debugging i found that elements are not getting initiallized
Define initialised. If you're expecting SafeArrayCreateEx to copy elements into the array for you, I think you're expecting too much. I think you'll find it just uses the IRecordInfo interface to determine how much storage the SAFEARRAY needs.
Have you seen this example[^]?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks...
i have created and used succesfully...
Thanks a lot
|
|
|
|
|
I am using VC++ 6.0 for developement.
I want to know how to find audio file advance properties like "Album","genre" etc
Please let me how to do this in vc++ 6.0
|
|
|
|
|
Different audio files like MP3, WAV, WMA, RA etc. etc. have different file formats.
The properties that you mentioned will be stored in different locations in different file formats.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I need to read a MP3 file.
Please let me know how to do this task
modified on Monday, March 2, 2009 1:05 AM
|
|
|
|
|
I'm pretty sure most audio files store properties like this in id3 tags....
I think id3lib [^] is an opensource C++ api.
|
|
|
|
|