Search Results

Search found 6123 results on 245 pages for 'unsigned char'.

Page 11/245 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Separating null byte separated UNICODE C string.

    - by Ramblingwood
    First off, this is NOT a duplicate of: http://stackoverflow.com/questions/1911053/turn-a-c-string-with-null-bytes-into-a-char-array , because the given answer doesn't work when the char *'s are Unicode. I think the problem is that because I am trying to use Unicode and thus wchar_t instead of char, the length of each character is different and thus, this doesn't work (it does in non-unicode): char *Buffer; // your null-separated strings char *Current; // Pointer to the current string // [...] for (Current = Buffer; *Current; Current += strlen(Current) + 1) printf("GetOpenFileName returned: %s\n", Current); Does anyone have a similar solution that works on Unicode strings? I have been banging my head on the this for over 4 hours now. C doesn't agree with me.

    Read the article

  • How can i convert a string into byte[] of unsigned int 32 C#

    - by Miroo
    i have string like "0x5D, 0x50, 0x68, 0xBE, 0xC9, 0xB3, 0x84, 0xFF" i wanna convert it into byte[] key= new byte[] { 0x5D, 0x50, 0x68, 0xBE, 0xC9, 0xB3, 0x84, 0xFF}; i thought about splitting the string by ',' then loop on it and setvalue into another byte[] in index of i string Key = "0x5D, 0x50, 0x68, 0xBE, 0xC9, 0xB3, 0x84, 0xFF"; string[] arr = Key.Split(','); byte[] keybyte= new byte[8]; for (int i = 0; i < arr.Length; i++) { keybyte.SetValue(Int32.Parse(arr[i].ToString()), i); } but seems like it doesn't work i get error in converting the string into unsigned int32 on the first beginning an help would be appreciated

    Read the article

  • C# - How to convert 10 bytes to unsigned long

    - by Justin
    Hey, I have 10 bytes - 4 bytes of low order, 4 bytes of high order, 2 bytes of highest order - that I need to convert to an unsigned long. I've tried a couple different methods but neither of them worked: Try #1: var id = BitConverter.ToUInt64(buffer, 0); Try #2: var id = GetID(buffer, 0); long GetID(byte[] buffer, int startIndex) { var lowOrderUnitId = BitConverter.ToUInt32(buffer, startIndex); var highOrderUnitId = BitConverter.ToUInt32(buffer, startIndex + 4); var highestOrderUnitId = BitConverter.ToUInt16(buffer, startIndex + 8); return lowOrderUnitId + (highOrderUnitId * 100000000) + (highestOrderUnitId * 10000000000000000); } Any help would be appreciated, thanks!

    Read the article

  • How to pass a const unsigned char * from c++ to c#

    - by tzup
    So I have a function in unmanaged c++ that gets called when some text happens to have "arrived": #using <MyParser.dll> ... void dump_body(const unsigned char *Body, int BodyLen) { // Need to pass the body to DumpBody, but as what type? ... lMyParser::Parser::DumpBody(???); } DumpBody is a function defined in a C# DLL that should take one parameter of type? Body holds an array of characters (text) of length BodyLen. There's obviously some marshalling to be done here but I have no idea how. Please help.

    Read the article

  • taglib link errors

    - by Vihaan Verma
    I m using taglib for one of my projects . The Debug/Release library is build using MSVC 10. On compiling the code with the library in taglib/taglib/Release some linker error are thrown . id3.cpp.1.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class TagLib::AudioPropertie s * __cdecl TagLib::FileRef::audioProperties(void)const " (__imp_?audioProperties@FileRef@TagLib@@QEBAPEAVAudioProp erties@2@XZ) referenced in function "struct MetaData __cdecl ID3::getMetaDataOfFile(class std::basic_string<char,st ruct std::char_traits<char>,class std::allocator<char> >)" (?getMetaDataOfFile@ID3@@YA?AUMetaData@@V?$basic_string@ DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) id3.cpp.1.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl TagLib::Stri ng::~String(void)" (__imp_??1String@TagLib@@UEAA@XZ) referenced in function "struct MetaData __cdecl ID3::getMetaDa taOfFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getMetaDataOfF ile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) id3.cpp.1.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char ,struct std::char_traits<char>,class std::allocator<char> > __cdecl TagLib::String::to8Bit(bool)const " (__imp_?to8 Bit@String@TagLib@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N@Z) referenced in function "struct MetaData __cdecl ID3::getMetaDataOfFile(class std::basic_string<char,struct std::char_traits<char>,class s td::allocator<char> >)" (?getMetaDataOfFile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator @D@2@@std@@@Z) id3.cpp.1.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl TagLib::File Ref::~FileRef(void)" (__imp_??1FileRef@TagLib@@UEAA@XZ) referenced in function "struct MetaData __cdecl ID3::getMet aDataOfFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getMetaData OfFile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) id3.cpp.1.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class TagLib::Tag * __cdecl TagLib::FileRef::tag(void)const " (__imp_?tag@FileRef@TagLib@@QEBAPEAVTag@2@XZ) referenced in function "struct Meta Data __cdecl ID3::getMetaDataOfFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator <char> >)" (?getMetaDataOfFile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z ) id3.cpp.1.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __cdecl TagLib::FileRef ::isNull(void)const " (__imp_?isNull@FileRef@TagLib@@QEBA_NXZ) referenced in function "struct MetaData __cdecl ID3: :getMetaDataOfFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getM etaDataOfFile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) id3.cpp.1.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl TagLib::FileRef::Fil eRef(class TagLib::FileName,bool,enum TagLib::AudioProperties::ReadStyle)" (__imp_??0FileRef@TagLib@@QEAA@VFileName @1@_NW4ReadStyle@AudioProperties@1@@Z) referenced in function "struct MetaData __cdecl ID3::getMetaDataOfFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getMetaDataOfFile@ID3@@YA?AU MetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) id3.cpp.1.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl TagLib::FileName::Fi leName(char const *)" (__imp_??0FileName@TagLib@@QEAA@PEBD@Z) referenced in function "struct MetaData __cdecl ID3:: getMetaDataOfFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getMe taDataOfFile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) I m only including tag.lib from taglib/taglib/Release folder . Is there some other library I m missing out?

    Read the article

  • Why this C program outputs a negative number?

    - by JMSA
    I have assigned the complement value in an unsigned variable. Then why this C program outputs a negative number? #include<stdio.h> #include<conio.h> int main() { unsigned int Value = 4; /* 4 = 0000 0000 0000 0100 */ unsigned int result = 0; result = ~ Value; /* -5 = 1111 1111 1111 1011 */ printf("result = %d", result); /* -5 */ getch(); return 0; }

    Read the article

  • C Population Count of unsigned 64-bit integer with a maximum value of 15

    - by BitTwiddler1011
    I use a population count (hamming weight) function intensively in a windows c application and have to optimize it as much as possible in order to boost performance. More than half the cases where I use the function I only need to know the value to a maximum of 15. The software will run on a wide range of processors, both old and new. I already make use of the POPCNT instruction when Intel's SSE4.2 or AMD's SSE4a is present, but would like to optimize the software implementation (used as a fall back if no SSE4 is present) as much as possible. Currently I have the following software implementation of the function: inline int population_count64(unsigned __int64 w) { w -= (w 1) & 0x5555555555555555ULL; w = (w & 0x3333333333333333ULL) + ((w 2) & 0x3333333333333333ULL); w = (w + (w 4)) & 0x0f0f0f0f0f0f0f0fULL; return int(w * 0x0101010101010101ULL) 56; } So to summarize: (1) I would like to know if it is possible to optimize this for the case when I only want to know the value to a maximum of 15. (2) Is there a faster software implementation (for both Intel and AMD CPU's) than the function above?

    Read the article

  • Convert binary unsigned vector to dec list

    - by Juan
    This code convert a unsigned long vector variable cR1 to NB_ERRORS numbers (in 'a' variable I print these numbers). for (l = 0; l < NB_ERRORS; ++l) { k = (l * EXT_DEGREE) / BIT_SIZE_OF_LONG; j = (l * EXT_DEGREE) % BIT_SIZE_OF_LONG; a = cR1[k] >> j; if(j + EXT_DEGREE > BIT_SIZE_OF_LONG) a ^= cR1[k + 1] << (BIT_SIZE_OF_LONG - j); a &= ((1 << EXT_DEGREE) - 1); printf("\na=%d\n",a); } For example I am have a cR1 with two elements that follow: 0,0,1,1,0,1,0,0,0,0,1,0,0,1,1,1,1,1,0,0,1,1,1,1,0,0,0,1,1,0,0,0,1,0,1,1,0,0,1,0,1,1,1,0,0,1,0,0,1,0,1,0,1,1,1,0,1,0,0,1,1,1,1,0, executing that code I get (44), (228, (243), (24), (77), (39), (117), (121). This code convert from right to left, I want modify to convert from right to left, Where I will be able to modify this? pdta: In the example case EXT_DEGREE = 8, BIT_SIZE_OF_LONG = 32

    Read the article

  • dynamic char array sizing

    - by droseman
    Hello, In my application, I have a char array defined which can take one of three options: "okay", "high", "low" which are then sent down a serial port to a remote device. I currently have the array sized to take the 4 character words plus carriage return and line feed, but when I have to send "low" I get a null character in the strings, which I am concerned would confuse the host terminal. array definition char mod1_status_char[6] = {'0','0','0','0','0','0'}; char mod2_status_char[6] = {'0','0','0','0','0','0'}; char mod3_status_char[6] = {'0','0','0','0','0','0'}; sample of switch case statement: void DCOKStatus(uint8_t *ptr_status) { uint8_t status = *ptr_status; switch (status) { case 0x00: strcpy(mod1_status_char, "okay"); strcpy(mod2_status_char, "okay"); strcpy(mod3_status_char, "okay"); break; case 0x10: strcpy(mod1_status_char, "okay"); strcpy(mod2_status_char, "okay"); strcpy(mod3_status_char, "low"); break; } This is the struct which makes the message string to send strcpy(MsgStatus_on.descriptor_msg, "$psu_"); MsgStatus_on.address01 = hex_addr[0]; MsgStatus_on.address02 = hex_addr[1]; MsgStatus_on.space01 = 0x20; strcpy(MsgStatus_on.cmdmsg01, "op_en op1_"); strcpy(MsgStatus_on.statusmsg01, mod1_status_char); MsgStatus_on.space02 = 0x20; strcpy(MsgStatus_on.cmdmsg02, "op2_"); strcpy(MsgStatus_on.statusmsg02, mod2_status_char); MsgStatus_on.space03 = 0x20; strcpy(MsgStatus_on.cmdmsg03, "op3_"); strcpy(MsgStatus_on.statusmsg03, mod3_status_char); MsgStatus_on.CR = 0x0D; MsgStatus_on.LF = 0x0A; and this sends the message void USARTWrite(char *object, uint32_t size) { GPIO_SetBits(GPIOB, GPIO_Pin_1); char *byte; for (byte = object; size--; ++byte) { USART_SendData(USART1,*byte); } Would anyone be able to suggest a good approach to dynamically size the array to one character shorter when I need to send "low"? Thanks

    Read the article

  • How to implement " char * ftoa(float num) " without sprintf() library function in C, C++ and JAVA

    - by SIVA
    Today I appeared for an interview, and the question was writing my own "char * ftoa(float num) " in C, C++ and Java. Yes, I know float numbers follow IEEE standard while allocating their memory, but I don't know float to char conversion by using Mantissa and Exponent in C. I don't have any idea to solve the above problem in C++ and JAVA. I/P to the ftoa(): 1.23 O/P from the ftoa(): 1.23 (char format). Thanks in advance ...

    Read the article

  • When does printf("%s", char*) stop printing?

    - by remagen
    In my class we are writing our own copy of C's malloc() function. To test my code (which can currently allocate space fine) I was using: char* ptr = my_malloc(6*sizeof(char)); memcpy(ptr, "Hello\n", 6*sizeof(char)); printf("%s", ptr); The output would typically be this: Hello Unprintable character Some debugging figured that my code wasn't causing this per say, as ptr's memory is as follows: [24 bytes of meta info][Number of requested bytes][Padding] So I figured that printf was reaching into the padding, which is just garbage. So I ran a test of: printf("%s", "test\nd"); and got: test d Which makes me wonder, when DOES printf("%s", char*) stop printing chars?

    Read the article

  • MySQL Query Error

    - by Nano HE
    I am debug my php forum. Before the error,I modified the DB table name from cdb_sessions to imc_forum_sessions successfully. I tried my best to debug with NetBeans but can't find the reason. Could you please have a look at my post below. Thank you. // It will run to else during debug if($sid) { if($discuz_uid) { $query = $db->query("SELECT s.sid, s.styleid, s.groupid='6' AS ipbanned, s.pageviews AS spageviews, s.lastolupdate, s.seccode, $membertablefields FROM {$tablepre}sessions s, {$tablepre}members m WHERE m.uid=s.uid AND s.sid='$sid' AND CONCAT_WS('.',s.ip1,s.ip2,s.ip3,s.ip4)='$onlineip' AND m.uid='$discuz_uid' AND m.password='$discuz_pw' AND m.secques='$discuz_secques'"); } else { $query = $db->query("SELECT sid, uid AS sessionuid, groupid, groupid='6' AS ipbanned, pageviews AS spageviews, styleid, lastolupdate, seccode FROM {$tablepre}sessions WHERE sid='$sid' AND CONCAT_WS('.',ip1,ip2,ip3,ip4)='$onlineip'"); } } MySQL data table exported as below CREATE TABLE IF NOT EXISTS `imc_forum_sessions` ( `sid` char(6) NOT NULL DEFAULT '', `ip1` tinyint(3) unsigned NOT NULL DEFAULT '0', `ip2` tinyint(3) unsigned NOT NULL DEFAULT '0', `ip3` tinyint(3) unsigned NOT NULL DEFAULT '0', `ip4` tinyint(3) unsigned NOT NULL DEFAULT '0', `uid` mediumint(8) unsigned NOT NULL DEFAULT '0', `username` char(15) NOT NULL DEFAULT '', `groupid` smallint(6) unsigned NOT NULL DEFAULT '0', `styleid` smallint(6) unsigned NOT NULL DEFAULT '0', `invisible` tinyint(1) NOT NULL DEFAULT '0', `action` tinyint(1) unsigned NOT NULL DEFAULT '0', `lastactivity` int(10) unsigned NOT NULL DEFAULT '0', `lastolupdate` int(10) unsigned NOT NULL DEFAULT '0', `pageviews` smallint(6) unsigned NOT NULL DEFAULT '0', `seccode` mediumint(6) unsigned NOT NULL DEFAULT '0', `fid` smallint(6) unsigned NOT NULL DEFAULT '0', `tid` mediumint(8) unsigned NOT NULL DEFAULT '0', `bloguid` mediumint(8) unsigned NOT NULL DEFAULT '0', UNIQUE KEY `sid` (`sid`), KEY `uid` (`uid`), KEY `bloguid` (`bloguid`) ) ENGINE=MEMORY DEFAULT CHARSET=utf8 MAX_ROWS=5000; -- -- Dumping data for table `imc_forum_sessions` -- INSERT INTO `imc_forum_sessions` (`sid`, `ip1`, `ip2`, `ip3`, `ip4`, `uid`, `username`, `groupid`, `styleid`, `invisible`, `action`, `lastactivity`, `lastolupdate`, `pageviews`, `seccode`, `fid`, `tid`, `bloguid`) VALUES ('NYC4r7', 127, 0, 0, 1, 0, '', 6, 5, 0, 3, 1271372018, 0, 0, 939015, 51, 303, 0); And the IE error showed, Time: 2010-4-16 7:12am Script: /forum/index.php SQL: SELECT sid, uid AS sessionuid, groupid, groupid='6' AS ipbanned, pageviews AS spageviews, styleid, lastolupdate, seccode FROM [Table]sessions WHERE sid='NYC4r7' AND CONCAT_WS('.',ip1,ip2,ip3,ip4)='127.0.0.1' Error: Table 'dbbbs.[Table]sessions' doesn't exist Errno.: 1146 Similar error report has beed dispatched to administrator before.

    Read the article

  • QT:QString to char conversion

    - by mawia
    hi! all, I was tryin to convert a QSting to char* type but by following methods,but those does'nt seem to work. // QLineEdit *line=new QLineEdit();{just to describe what is line here} QString temp=line->text(); char *str=(char *)malloc(10); QByteArray ba=temp.toLatin1(); strcpy(str,ba.data()); can you elobrate the possible flaw with this method ,or tell alternative method.

    Read the article

  • SQL: ATER COLUMN to shorter CHAR(n) type

    - by Rising Star
    I'm working with MS SQL SERVER 2003. I want to change a column in one of my tables to have fewer characters in the entries. This is identical to this question: http://stackoverflow.com/questions/2281336/altering-a-table-column-to-accept-more-characters except for the fact that I want fewer characters instead of more. I have a column in one of my tables that holds nine-digit entries. A developer previously working on the table mistakenly set the column to hold ten-digit entries. I need to change the type from CHAR(10) to CHAR(9). Following the instructions from the discussion linked above, I wrote the statement ALTER TABLE [MY_TABLE] ALTER COLUMN [MY_COLUMN] CHAR(9); This returns the error message "String or binary data would be truncated". I see that my nine-digit strings have a space appended to make them ten digits. How do I tell SQL Server to discard the extra space and convert my column to a CHAR(9) type?

    Read the article

  • vector<string> or vector<char *>?

    - by Aaron
    Question: What is the difference between: vector<string> and vector<char *>? How would I pass a value of data type: string to a function, that specifically accepts: const char *? For instance: vector<string> args(argv, argv + argc); vector<string>::iterator i; void foo (const char *); //*i I understand using vector<char *>: I'll have to copy the data, as well as the pointer Edit: Thanks for input!

    Read the article

  • copying a short int to a char array

    - by cateof
    I have a short integer variable called s_int that holds value = 2 unsighed short s_int = 2; I want to copy this number to a char array to the first and second position of a char array. Let's say we have char buffer[10];. We want the two bytes of s_int to be copied at buffer[0] and buffer[1]. How can I do it?

    Read the article

  • Haskell: variant of `show` that doesn't wrap String and Char in quotes

    - by Joey Adams
    I'd like a variant of show (let's call it label) that acts just like show, except that it doesn't wrap Strings in " " or Chars in ' '. Examples: > label 5 "5" > label "hello" "hello" > label 'c' "c" I tried implementing this manually, but I ran into some walls. Here is what I tried: {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} module Label where class (Show a) => Label a where label :: a -> String instance Label [Char] where label str = str instance Label Char where label c = [c] -- Default case instance Show a => Label a where label x = show x However, because the default case's class overlaps instance Label [Char] and instance Label Char, those types don't work with the label function. Is there a library function that provides this functionality? If not, is there a workaround to get the above code to work?

    Read the article

  • Convert wchar_t to char

    - by Yan Cheng CHEOK
    I was wondering is it safe to do so? wchar_t wide = /* something */; assert(wide >= 0 && wide < 256 &&); char myChar = static_cast<char>(wide); If I am pretty sure the wide char will fall within ASCII range.

    Read the article

  • Convert string to char

    - by Orsol
    Hi. I get from another class string that must be converted to char. It usually contains only one char and that's not a problem. But control chars i receive like '\n' or '\t'. Is there standard methods to convert this to endline or tab char or i need to parse it myself?

    Read the article

  • Changing memory address of a char*

    - by Randall Flagg
    I have the following code: str = "ABCD"; //0x001135F8 newStr = "EFGH"; //0x008F5740 *str after realloc at 5th position - //0x001135FC I want it to point to: 0x008F5740 void str_cat(char** str, char* newStr) { int i; realloc(*str, strlen(*str) + strlen(newStr) + 1); //*str is now 9 length long // I want to change the memory reference value of the 5th char in *str to point to newStr. // Is this possible? // &((*str) + strlen(*str)) = (char*)&newStr; //This is my problem (I think) }

    Read the article

  • C++ vector of char array

    - by Stuart
    I am trying to write a program that has a vector of char arrays and am have some problems. char test [] = { 'a', 'b', 'c', 'd', 'e' }; vector<char[]> v; v.push_back(test); Sorry this has to be a char array because I need to be able to generate lists of chars as I am trying to get an output something like. a a a b a c a d a e b a b c Can anyone point me in the right direction? Thanks

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >