Search Results

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

Page 4/245 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Converting a const char* into a double

    - by Koning Baard
    I am trying to convert a const char* to a double precision floating point number: int main(const int argc, const char *argv[]) { int i; double numbers[argc - 1]; for(i = 1; i < argc, i += 1) { /* -- Convert each argv into a double and put it in `number` */ } /* ... */ return 0; } Can anyone help me? Thanks

    Read the article

  • Char * reallocation in C++

    - by JTom
    Hi, I need to store a certain amount of data in the "char *" in C++, because I want to avoid std::string to run out of memory, when exceeding max_size(). But the data comes in data blocks from the network so I need to use reallocation every time I get the data block. Is there any elegant solution for char * reallocation and concatenation in C++?

    Read the article

  • Deleting dynamic array of char in C++.

    - by anonymous
    I have this class, with the atribute 'word' class Node { char *word; Inside the Node constructor, I do this asignation: word = new char[strlen(someword)]; In the destructor of the Node class, I try to delete the contents pointed by word: delete []word; I obtain the next message after executing the programs: "Heap block at 003E4F48 modified at 003E4F51 past requested size of 1" What am I not doing well?

    Read the article

  • Why doesn't GCC produce a warning when assigning a signed literal to an unsigned type?

    - by maerics
    Several questions on this website reveal pitfalls when mixing signed and unsigned types and most compilers seem to do a good job about generating warnings of this type. However, GCC doesn't seem to care when assigning a signed constant to an unsigned type! Consider the following program: /* foo.c */ #include <stdio.h> int main(void) { unsigned int x=20, y=-30; if (x > y) { printf("%d > %d\n", x, y); } else { printf("%d <= %d\n", x, y); } return 0; } Compilation with GCC 4.2.1 as below produces no output on the console: gcc -Werror -Wall -Wextra -pedantic foo.c -o foo The resulting executable generates the following output: $ ./foo 20 <= -30 Is there some reason that GCC doesn't generate any warning or error message when assigning the signed value -30 to the unsigned integer variable y?

    Read the article

  • C/C++ enum and char * array

    - by Eric M
    Ran accross the following code in an article and didn't think it was standard C/C++ syntax for the char* array. As a test, both Visual C++ (visual studio 2005) and C++ Builder Rad XE both reject the 2nd line. Without using #defines, anyone have any tricks/tips for keeping enums and a string array sort of in sync without resorting to STL ? More of a curiosity question. enum TCOLOR { RED, GREEN, BLUE }; char *TNCOLOR[] = { [RED]="Red", [GREEN]="Green", [BLUE]="Blue" }; as an aside, the article this came from is quite old and I believe this might work under GCC but have not tested.

    Read the article

  • Java, JavaCC: How to check if a char (or char pair) is inside a given UTF32 range?

    - by java.is.for.desktop
    Hello, everyone! I am referring to the XML 1.1 spec. Look at the definition of NameStartChar: NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] If I interpret this correctly, the last range (#x10000-#xEFFFF) goes beyond the UTF16 range of Java's char type. So it must be UTF32, right? So, I need to check pairs of char against this range, instead of single chars, right? My questions are: How do I check for such character ranges using standard Java methods? How is it possible to define such ranges in JavaCC? JavaCC complains about \u10000 and \uEFFFF Thank you! NOTE: Don't worry, I am not trying to write an own XML-parser. I need those character ranges for other reasons.

    Read the article

  • Convert 2 char into 1 int

    - by Leo
    I have 2 chars: HIGH and LOW and I'd like to convert them to an int corresponding to HIGH + the 2 left bits from LOW. I tried somethine like : char *HIGH; char *LOW; HIGH = 152; LOW = 12; int result; result += (LOW + 6); result += (LOW + 7)*2; result += HIGH*4; result += (HIGH + 1)*8; result += (HIGH + 2)*16; result += (HIGH + 3)*32; result += (HIGH + 4)*64; result += (HIGH + 5)*128; result += (HIGH + 6)*256; result += (HIGH + 7)*512; return result; But it doesn't work and I don't understand why.

    Read the article

  • Best way to handle storing (possibly NULL) char * in a std::string

    - by John
    class MyClass { public: void setVar(const char *str); private: std::string mStr; int maxLength; //we only store string up to this length }; What's the best approach to implement setVar when the external code is quite likely to pass in NULL for an empty string (and cannot be changed)? I currently do something a bit like: void MyClass::setVar(const char *str) { mStr.assign(str ? str : "",maxLength); } But it seems kind of messy. ideas?

    Read the article

  • Convert Unicode char to closest (most similar) char in ASCII (.net)

    - by Andrey
    Hi all! Do you have any idea how to covert different Unicode characters to their closest ASCII equivalents? Like Ä - A. A googled but didn't find any suitable solution. Trick Encoding.ASCII.GetBytes("Ä")[0] didn't work. (Result was ?). I found that there is class Encoder that has Fallback property that is exactly for cases when char can't be converted, but implementations (EncoderReplacementFallback) are stupid and convert to ?. Any ideas? Thanks, Andrey

    Read the article

  • How do you convert an unsigned int[16] of hexidecimal to an unsigned char array without losing any information?

    - by user1068636
    I have a unsigned int[16] array that when printed out looks like this: 4418703544ED3F688AC208F53343AA59 The code used to print it out is this: for (i = 0; i < 16; i++) printf("%X", CipherBlock[i] / 16), printf("%X",CipherBlock[i] % 16); printf("\n"); I need to pass this unsigned int array "CipherBlock" into a decrypt() method that only takes unsigned char *. How do correctly memcpy everything from the "CipherBlock" array into an unsigned char array without losing information? My understanding is an unsigned int is 4 bytes and unsigned char 1 byte. Since "CipherBlock" is 16 unsigned integers, the total size in bytes = 16 * 4 = 64 bytes. Does this mean my unsigned char[] array needs to be 64 in length? If so, would the following work? unsigned char arr[64] = { '\0' }; memcpy(arr,CipherBlock,64); This does not seem to work. For some reason it only copies the the first byte of "CipherBlock" into "arr". The rest of "arr" is '\0' thereafter.

    Read the article

  • Non ASCII char in PHP?

    - by domagoj412
    Hello, I am trying to send something to serial port (r232) with PHP. I am using this class: http://www.phpclasses.org/browse/package/3679.html The problem is that I am allowed to send only 1 byte. But if I send something like "1", I am actually sending 49 (ASCII for 1). Instead of send("1"), I tried with send(1) but it is no good, because this is integer which has 2 bytes. So is there a way to send a "real" char, not ASCII equivalent?

    Read the article

  • Possible loss of precision; extracting char from string

    - by Troy
    I am getting a string from the user and then doing some checking to make sure it is valid, here is the code I have been using; char digit= userInput.charAt(0) - '0'; This had been working fine until I did some work on another method, I went to compile and have been receiving a 'possible loss of precision' error since then. What am I doing wrong?

    Read the article

  • A few questions about char pointers.

    - by m4design
    1- How does this work: char *ptr = "hi"; Now the compiler will put this string in the memory (I'm guessing the stack), and create a pointer to it? Is this is how it works? 2- Also if it is created locally in a function, when the function returns will the memory occupied by the string be freed? 3- Last but not least, why is this not allowed: ptr[0] = 'H'; ?

    Read the article

  • How to make a copy of a char and not a reference in C++

    - by Phenom
    If I declare a function like this: string hash (char* key) then any change I make to key will also change it's value when the function exits, correct? I want to make a copy of it in the function so that I can safely change it without changing the original value. I tried this, but it doesn't work. string temp = key; How can it be done?

    Read the article

  • What does 'unsigned temp:3' means

    - by Munir Ahmed
    Hi, I'm trying to map a C structure to Java using JNA. I came across something that I've never seen. The struct definition is as follow, struct op { unsigned op_type:9; //---> what does this means? unsigned op_opt:1; unsigned op_latefree:1; unsigned op_latefreed:1; unsigned op_attached:1; unsigned op_spare:3; U8 op_flags; U8 op_private; }; you can see some variable being defined like unsigned op_attached:1 and I'm unsure what would that mean: would that effect number of bytes to be allocated for this particular variable? any help? Thanks, Munir

    Read the article

  • C++ struct containing unsigned char and int bug

    - by powerfear
    Ok i have a struct in my C++ program that is like this: struct thestruct { unsigned char var1; unsigned char var2; unsigned char var3[2]; unsigned char var4; unsigned char var5[8]; int var6; unsigned char var7[4]; }; When i use this struct, 3 random bytes get added before the "var6", if i delete "var5" it's still before "var6" so i know it's always before the "var6". But if i remove the "var6" then the 3 extra bytes are gone. If i only use a struct with a int in it, there is no extra bytes. So there seem to be a conflict between the unsigned char and the int, how can i fix that?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >