Search Results

Search found 5202 results on 209 pages for 'char'.

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

  • Why do C++ streams use char instead of unsigned char?

    - by Johannes Schaub - litb
    I've always wondered why the C++ Standard library has instantiated basic_[io]stream and all its variants using the char type instead of the unsigned char type. char means (depending on whether it is signed or not) you can have overflow and underflow for operations like get(), which will lead to implementation-defined value of the variables involved. Another example is when you want to output a byte, unformatted, to an ostream using its put function. Any ideas? Note: I'm still not really convinced. So if you know the definitive answer, you can still post it indeed.

    Read the article

  • Need help for this syntax: "#define LEDs (char *) 0x0003010"

    - by Noge
    I'm doing programming of a softcore processor, Nios II from Altera, below is the code in one of the tutorial, I manage to get the code working by testing it on the hardware (DE2 board), however, I could not understand the code. #define Switches (volatile char *) 0x0003000 #define LEDs (char *) 0x0003010 void main() { while (1) *LEDs = *Switches; } What I know about #define is that, it is either used to define a constant, or a macro, but why in the above code, there are casting like, (char *) 0x0003010, in #define? why the 2 constants, Switches and LEDs act like a variable instead of a constant? Thanks in advance !

    Read the article

  • C++'s char * by swig got problem in Python 3.0

    - by gpliu3
    Our C++ lib works fine with Python2.4 using Swig, returning a C++ char* back to a python str. But this solution hit problem in Python3.0, error is: Exception=(, UnicodeDecodeError('utf8', b"\xb6\x9d\xa.....",0, 1, 'unexpected code byte') Our definition is like(working fine in Python 2.4): void cGetPubModulus( void* pSslRsa, char* cMod, int* nLen ); %include "cstring.i" %cstring_output_withsize( char* cMod, int* nLen ); Suspect swig is doing a Bytes-Str conversion automatically. In python2.4 it can be implicit but in Python3.0 it's no long allowed.. Anyone got a good idea? thanks

    Read the article

  • stack dump accessing malloc char array

    - by robUK
    Hello, gcc 4.4.3 c89 I have the following source code. And getting a stack dump on the printf. char **devices; devices = malloc(10 * sizeof(char*)); strcpy(devices[0], "smxxxx1"); printf("[ %s ]\n", devices[0]); /* Stack dump trying to print */ I am thinking that this should create an char array like this. devices[0] devices[1] devices[2] devices[4] etc And each element I can store my strings. Many thanks for any suggestions,

    Read the article

  • Allocating memory for a array to char pointer

    - by nunos
    The following piece of code gives a segmentation fault when allocating memory for the last arg. What am I doing wrong? Thanks. int n_args = 0, i = 0; while (line[i] != '\0') { if (isspace(line[i++])) n_args++; } for (i = 0; i < n_args; i++) command = malloc (n_args * sizeof(char*)); char* arg = NULL; arg = strtok(line, " \n"); while (arg != NULL) { arg = strtok(NULL, " \n"); command[i] = malloc ( (strlen(arg)+1) * sizeof(char) ); strcpy(command[i], arg); i++; } Thanks.

    Read the article

  • Feed char array into stdin

    - by Brian Lindsey
    I am writing a parser for a mini scripting language. Some of my grammar rules require jumping to a different location in the file to obtain information. There doesn't seem to be a straightforward way to accomplish this. So, I was thinking about loading my data files into a char array array and parsing line by line. This will allow me to jump all over the array with ease. My question is, is it possible to feed char arrays (i.e. char *) into stdin, so I can easily invoke the yyparse() function as needed.

    Read the article

  • C++ putting a 2d array of floats into a char*

    - by sam
    Hello, I'm trying to take a 2d vector of floats (input) and put them into a char* (output) in c++. void foo(const std::vector<std::vector<float> > &input, char* &output ) { char charBuf[sizeof(output)]; int counter = 0; for(unsigned int i=0; i<input.size(); i++) { for(unsigned int p=0; p<input.at(i).size(); p++) { //what the heck goes here } }

    Read the article

  • How to initialize static const char array for ASCII codes [C++]

    - by Janney
    I want to initialize a static const char array with ASCII codes in a constructor, here's my code: class Card { public: Suit(void) { static const char *Suit[4] = {0x03, 0x04, 0x05, 0x06}; // here's the problem static const string *Rank[ 13 ] = {'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'}; // and here. } However i got a whole lot of errors stating that 'initializing' : cannot convert from 'char' to 'const std::string *' 'initializing' : cannot convert from 'int' to 'const std::string *' please help me! Thank you so much.

    Read the article

  • Beginner C++ Question

    - by Donal Rafferty
    I have followed the code example here toupper c++ example And implemented it in my own code as follows void CharString::MakeUpper() { char* str[strlen(m_pString)]; int i=0; str[strlen(m_pString)]=m_pString; char* c; while (str[i]) { c=str[i]; putchar (toupper(c)); i++; } } But this gives me the following compiler error CharString.cpp: In member function 'void CharString::MakeUpper()': CharString.cpp:276: error: invalid conversion from 'char*' to 'int' CharString.cpp:276: error: initializing argument 1of 'int toupper(int)' CharString.cpp: In member function 'void CharString::MakeLower()': This is line 276 putchar (toupper(c)); I understand that toupper is looking for int as a parameter and returns an int also, is that the problem? If so how does the example work?

    Read the article

  • boost::asio buffer impossible to convert parameter from char to const mutable_buffer&

    - by Ekyo777
    visual studio tells me "error C2664: 'boost::asio::mutable_buffer::mutable_buffer(const boost::asio::mutable_buffer&)': impossible to convert parameter 1 from 'char' to 'const boost::asio::mutable_buffer&' at line 163 of consuming_buffers.hpp" I am unsure of why this happen nor how to solve it(otherwise I wouldn't ask this ^^') but I think it could be related to those functions.. even tough I tried them in another project and everything worked fine... but I can hardly find what's different so... here comes code that could be relevant, if anything useful seems to be missing I'll be glad to send it. packets are all instances of this class. class CPacketBase { protected: const unsigned short _packet_type; const size_t _size; char* _data; public: CPacketBase(unsigned short packet_type, size_t size); ~CPacketBase(); size_t get_size(); const unsigned short& get_type(); virtual char* get(); virtual void set(char*); }; this sends a given packet template <typename Handler> void async_write(CPacketBase* packet, Handler handler) { std::string outbuf; outbuf.resize(packet->get_size()); outbuf = packet->get(); boost::asio::async_write( _socket , boost::asio::buffer(outbuf, packet->get_size()) , handler); } this enable reading packets and calls a function that decodes the packet's header(unsigned short) and resize the buffer to send it to another function that reads the real data from the packet template <typename Handler> void async_read(CPacketBase* packet, Handler handler) { void (CTCPConnection::*f)( const boost::system::error_code& , CPacketBase*, boost::tuple<Handler>) = &CTCPConnection::handle_read_header<Handler>; boost::asio::async_read(_socket, _buffer_data , boost::bind( f , this , boost::asio::placeholders::error , packet , boost::make_tuple(handler))); } and this is called by async_read once a packet is received template <typename Handler> void handle_read_header(const boost::system::error_code& error, CPacketBase* packet, boost::tuple<Handler> handler) { if (error) { boost::get<0>(handler)(error); } else { // Figures packet type unsigned short packet_type = *((unsigned short*) _buffer_data.c_str()); // create new packet according to type delete packet; ... // read packet's data _buffer_data.resize(packet->get_size()-2); // minus header size void (CTCPConnection::*f)( const boost::system::error_code& , CPacketBase*, boost::tuple<Handler>) = &CTCPConnection::handle_read_data<Handler>; boost::asio::async_read(_socket, _buffer_data , boost::bind( f , this , boost::asio::placeholders::error , packet , handler)); } }

    Read the article

  • Objective-C int to char

    - by teepusink
    Hi, How do I convert an int to a char and also back from char to int? e.g 12345 == abcde Right now I have it using a whole bunch of case statement, wonder if there is a smarter way of doing that? Thanks, Tee

    Read the article

  • Compare equality of char[] in C

    - by rksprst
    I have two variables: char charTime[] = "TIME"; char buf[] = "SOMETHINGELSE"; I want to check if these two are equal... using charTime == buf doesn't work. What should I use, and can someone explain why using == doesn't work? Would this action be different in C and C++?

    Read the article

  • Jquery Plugins/Autocomplete Special Char problem

    - by Yetkin EREN
    Hi; i use that plugin for autocomplate; docs.jquery.com/Plugins/Autocomplete but i have a problem with spacial chars. if a special char first char of a word, this char has being ignored and if its not first char, chars before that has being ignored. for example: "slk" cant found but if i type "lk" "slk" found and if i type öd "aöd" found. i made a test page; http://www.yetkineren.com/Autocomplete/oto.html and tahts the code thanks.. <html> <head> <meta http-equiv="Content-Language" content="tr"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9"> <script src="http://code.jquery.com/jquery-latest.js"></script> <link rel="stylesheet" href="jquery.autocomplete.css" type="text/css" /> <script type="text/javascript" src="encoder.js"></script> <script type="text/javascript" src="Scripts/jquery.bgiframe.min.js"></script> <script type="text/javascript" src="Scripts/jquery.autocomplete.js"></script> <script> $(document).ready(function(){ var gata=[ {"text": '21.png resmi aöd', "value": '21.png'}, {"text": '21.png resmi cöd', "value": '21.png'}, {"text": '21.png resmi acd', "value": '21.png'}, {"text": '21.png resmi aéd', "value": '21.png'}, {"text": '42.png resmi ésd', "value": '42.png'}, {"text": '63.png resmi aId', "value": '63.png'}, {"text": '34.png resmi Çsd', "value": '34.png'}, {"text": '65.png resmi jkl', "value": '65.png'}, {"text": '65.png resmi Gkl', "value": '65.png'}, {"text": '65.png resmi ökl', "value": '65.png'}, {"text": '65.png resmi slk', "value": '65.png'}, {"text": '65.png resmi lsk', "value": '65.png'}, {"text": '65.png resmi slk', "value": '65.png'}, {"text": '36.png resmi &#351;lk', "value": '36.png'} ]; $('#eksampil').autocomplete(gata, { width: 300, scroll: true, scrollHeight: 300, matchContains: "word", mustMatch: true, formatItem: function(row, i) { return i+". result <img src='images/" + row.value + "'/> " + row.text }, formatMatch: function(row) { //Encoder.EncodeType="entity"; return row.text //Encoder.EncodeType="entity"; //Encoder.htmlDecode( //Encoder.htmlEncode(i); }, formatResult: function(row) { return row.text } }); }); </script> </head> <body> <br> type "re" for see all: <input id="eksampil" /><br> </body> </html>

    Read the article

  • Need to convert string/char to ascii values.

    - by SA
    Hi, I need to convert char to hex values. Refer to the Ascii table but I have a few examples listed below: char 1 = 31 2 = 32 3 = 33 4 = 34 5 = 35 A = 41 a = 61 etc Therefore string str = "12345"; Need to get the converted str = "3132333435"

    Read the article

  • How to overwrite an array of char pointers with a larger list of char pointers?

    - by Casey
    My function is being passed a struct containing, among other things, a NULL terminated array of pointers to words making up a command with arguments. I'm performing a glob match on the list of arguments, to expand them into a full list of files, then I want to replace the passed argument array with the new expanded one. The globbing is working fine, that is, g.gl_pathv is populated with the list of expected files. However, I am having trouble copying this array into the struct I was given. #include <glob.h> struct command { char **argv; // other fields... } void myFunction( struct command * cmd ) { char **p = cmd->argv; char* program = *p++; // save the program name (e.g 'ls', and increment to the first argument glob_t g; memset(&g, 0, sizeof(g)); g.gl_offs = 1; int res = glob(*p++, GLOB_DOOFFS, NULL, &g); glob_handle_res(res); while (*p) { res = glob(*p, GLOB_DOOFFS | GLOB_APPEND, NULL, &g); glob_handle_res(res); } if( g.gl_pathc <= 0 ) { globfree(&g); } cmd->argv = malloc((g.gl_pathc + g.gl_offs) * sizeof *cmd->argv); if (cmd->argv == NULL) { sys_fatal_error("pattern_expand: malloc failed\n");} // copy over the arguments size_t i = g.gl_offs; for (; i < g.gl_pathc + g.gl_offs; ++i) cmd->argv[i] = strdup(g.gl_pathv[i]); // insert the original program name cmd->argv[0] = strdup(program); ** cmd->argv[g.gl_pathc + g.gl_offs] = 0; ** globfree(&g); } void command_free(struct esh_command * cmd) { char ** p = cmd->argv; while (*p) { free(*p++); // Segfaults here, was it already freed? } free(cmd->argv); free(cmd); } Edit 1: Also, I realized I need to stick program back in there as cmd-argv[0] Edit 2: Added call to calloc Edit 3: Edit mem management with tips from Alok Edit 4: More tips from alok Edit 5: Almost working.. the app segfaults when freeing the command struct Finally: Seems like I was missing the terminating NULL, so adding the line: cmd->argv[g.gl_pathc + g.gl_offs] = 0; seemed to make it work.

    Read the article

  • Get a char from a CString

    - by Sunscreen
    I have created a function that has as input a char szMyChar; (using it in a switch statement). Now I have a CString havong just a char, lets say CString strString = "A"; An option to call the function could be: if (strString == "A") CallMyFunc('A'); though it is clumsy. I tried atoi (returns 0) and casting though neither works. Any ideas? Thanks, Sun

    Read the article

  • a problem with char** in c

    - by sagi
    hello i have an char** arr which is an array of strings and i want to erase the 2 last cell of the array or maybe to create a new char** but without those last 2 cells thank you very much.

    Read the article

  • Accessing char* after assigning its value C

    - by iSight
    Hi, I have assign the value of a member variable as under: myValue = (char*)malloc(strlen(inValue) * sizeof(char)); strcpy(mValue, inValue); while assigning it the value was proper as(taking printf output): http://www.w3.org/2001/XMLSchema But, when i get its value after wards i get it as: http://www.w3.org/2001/XMLSchema(! What could be the problem for this issue

    Read the article

  • Scope of const char*

    - by Neeraj
    Consider this code: const char* someFun() { // ... some stuff return "Some text!!" } int main() { { // Block: A const char* retStr = someFun(); // use retStr } } My question is in the function sumFun() where is "some Text!!", stored (i think may be in some static area in ROM) and what will be its scope? Will the memory pointed by retStr be occupied throughout the program or be released once the block A exits? -- Thanks

    Read the article

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