Line 43 points at the snprintf() command.I think the error has to do with the function being virtual and the const after the function definition, however although I have been looking really hard I have not being able to find the reason nor the solution to the problem.
One workaround that I know is moving the block of source withing the virtual function, in the constructor, however having read around (boost library exceptions tutorials) it specifically said that formating of errors messages should not take place withing the construction of objects because we are risking throwing an exceptions and messing up the flow order.
I�m developing c++ application which is run on linux. I have a const wchar_t* which is returned from a method. I have a FILE * _pFile which is open for read/write.I need to write that const wchar_t* to that file. I used fprintf() to write other data types. Can I used fprintf method to do that also? If so how can I covert const wchar_t* to const char*
Programming in C.I have two char arrays.char buf1[1024];char buf2[1024];Aren't buf1 and buf2 also pointers?I read in 1024 bytes into buf1 which contain about 300 bytes of characters with newlines. The data is basically a few English sentences. I'm trying to scan buf1 for newlines and then stop at the 1st newline and copy the rest of the data from that 1st newline into buf2.So I run a for loop to look for that new line.
i define variable of type char (range -128 to 127). when i tried to print the value after assigning a -ve value to it it displaying a +ve value of that -ve value(256+value).
I've just updated my linux system (Debian) and went to compile some code I'm working on. However it causes some problems, presumable because of GCC up dates. I get many of my subject line errors for example
../../common/Version_Control.cpp: In function int VersionControl(): ../../common/Version_Control.cpp:55: warning: deprecated conversion from string constant to char*
So I check up the error and it comes from my error handler code which is a function
I simply want to read a file "data.txt" line by line Then char by char and add them into a result var. The file is supossed to always contain numeric values
I am trying, using checkinstall to make eboard to enable use of this program with a DGT electronic chessboard (option not available in the program included in the repositories) according to the instructions given here. After the preliminaries, namely downloading and extracting the source from: [URL]-1.1.1.tar.bz2./configure runs fine but (after su-ing to root), both make install & checkinstall fail after numerous warnings about "deprecated conversion" like:
Code:
board.cc:55: warning: deprecated conversion from string constant to 'char*' board.cc:157: warning: deprecated conversion from string constant to 'char*' board.cc: In function 'gboolean board_expose_event(GtkWidget*, GdkEventExpose*, void*)': board.cc:1414: warning: deprecated conversion from string constant to 'char*' bugpane.cc:304: warning: deprecated conversion from string constant to 'char*'
I've modified a program to show * instead of letters when typing a password. I'm trying to make it so that when pressing backspace a * will be removed.Here's a rough example. The problem is that when trying to do this in the real program,' is not recognized as backspace.
I'm writing the Diffie-Hellman key exchange system using GMP to handle big integers. For the most part, everything works. I can convert the string to mpz_t, set up the keys and everything, and encrypt it fine. Its the decrypting I'm having issues with. What I'm using is mpz_xor() for both. To encrypt I'm doing mpz_xor(buffer, mpz_of_text, secret_key), and to decrypt I'm doing mpz_xor(buffer, mpz_of_cipher, secret_key).
For one character, it semi-works...it'll decrypt it fine, but it'll return it as it's ASCII value (i.e.: if I encrypt "A", it'll decrypt it as 65). Which, I can easily just do sprintf(decrypted_buffer, "%c", 65) for example and be fine. But, when I'm sending text bigger than one character, the encryption for AB gives me something like 1061043 after running the decrypting xor on it.
Has anyone ever done this before or can point me in some directions? Perhaps other algorithms to try? I know XOR isn't the most secure encryption method to use, but at the time I wasn't sure what else to use. I'm really just having a hard time trying to convert a mpz_t to a character string. I've looked at mpz_get_str() and it works before running encryption (i.e.: using mpz_set_str() to create a mpz of a string, then calling mpz_get_str() to change it back). Maybe my XOR method is wrong? Here's the code I'm using:
Code:
/** * str2mpz() * b The current buffer of text to convert [in] * m The mpz_t variable to store converted text [out]
I am trying to simulate a shell. So what I do is checking of having the parameters from standard input, suc as "/bin/ls -l /home/france/Documents", and then passing them to function execute, which at some point calls execvp(argv[0],argv)The problem is that I don't succeed in using these arguments, while if I call execvp(paramList[0],paramList) it works!!!! Where paramList is exactly what I would put on standard input, but defined statically.
I would like to create a small C tool. I encounter a problem of how to make a function to check an input chars contains numbers (started from the second element).
Some samples:
char *mychar= "a3547"; (The result of function checking this is true) char *another_char = "t6548"; (The result of function checking this is true) char *next_char = "appl3"; (The result of function checking this is false) char *new_char = "b1aa3"; (The result of function checking this is false)
Can anyone please suggest me how can we convert a wide char data in linux which is of 32 bit to a 16bit data. I have a file which has 16bit binary data? Could any one please give me ideas.
How to remove alternate char from file using shell script? If the file content is "1234567890" the output file should be "24680". sed 's/(.)(.)/2/g' filename Now there may be small modification to generate two alternate byte, what it should be? If the file content is "1234567890" the output file should be "125689".
I'm writing a code to get the index of the last occurrence of a given substring in a string.
Code: int StringHandler::lastIndexOf(string src, const string s) { unsigned int lastIndex = string::npos; if (src.find(s, 0) == string::npos) { return -1; } else { bool isLast = false; unsigned int i = 0; do { lastIndex = src.find(s, i); if (lastIndex != string::npos) { i = lastIndex + 1; if (i == src.size()) { isLast = true; } } else { isLast = true; } } while (!isLast); } return lastIndex; }
My problem is: execution steps into an if with a false condition! Check the values of i and src.size() at the right panel. How could be possible for the program to run the highlighted statement? The if condition above is false! [URL]. I could use char arrays, for example, but this kind of false validation has happened to me more than once, I'm using G++ 4.5 with these flags: -O0 -g -Wall -c
Program in CSay I have a char array of 1024 bytes called buf1.But I only want to print the chars in index 0 up to index 30. I know I could do this with a for loop. But is there any other way? What about maybe storing from 31-1024 to another char array say buf2 with strcpy and somehow popping 31+ out of the buf1 char array?