C++ :: Converting Strings In Application
Jun 8, 2014
I am having trouble converting strings in my application.
This is the code that is eventually getting called, the first parameter takes a LPCWSTR
Code:
hr = m_pGraph->RenderFile(m_filePath, NULL); // takes LPCWSTR This is where the trouble begins.
The compiler shows that sResult is proper but after I try to convert a std::string to a wchar it prints garbage
Code: const wchar_t* m_filePath = (wchar_t *) oDb->GetNext().c_str();
Code:
std::string CSqlLiteDatabase::GetNext() {
sqlite3_stmt *oStmt = nullptr;
std::string sql = "SELECT path || filename FROM table WHERE id = 1";
char message[255];
[Code] ....
View 6 Replies
ADVERTISEMENT
Jun 10, 2013
As a starter project I want convert a Neural net app from "AI Techniques for Game Programming (2002 Buckland)" to a Visual C++ CLI Forms application. I have created the interface and now I have to rewrite the in/output routines, amongst other things.
First question I have has to do with variable initialization used by Buckland. Code looks like this:
Excerpt from header file (CNeuralNet.h):
//-------------------------------------------------------------------
//define neuron struct
//-------------------------------------------------------------------
struct SNeuron
{
//the number of inputs into the neuron
int m_NumInputs;
//the weights for each input
vector<double>m_vecWeight;
[code]....
Question I have: what is the the function of ": m_NumInputs(NumInputs+1)" after the method declaration? Buckland does this in many places in his code. In this case it's a struct, but he does it with classes too.
View 3 Replies
View Related
Feb 8, 2014
Code for converting strings to Dates in C++.
Example: What is the date:
User response: 12/05/14
Any way I can code this to recognize it as a date, and make it so that the date is sortable? Not referring to the system date, but a user input date.
View 1 Replies
View Related
Mar 14, 2014
I want to read a Bitmap file in C language and produce the binary equivalent of it in the form of 0's and 1's.
View 1 Replies
View Related
Aug 4, 2013
okay so this program is basically getting the files from user input then reading the original file and convert the string into a uppercase/lowercase form and save it into another file. Is there a way to save the string from the first file to a variable then convertin the string in the variable and copy that onto the new file? So far i have
Code:
#include <stdio.h>
#include <string.h>
int main() {
[Code].....
View 1 Replies
View Related
Aug 26, 2014
I am trying to convert multiple lines of strings to double with std::stod .... I used the code found on the website:
#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
int main() {
std::string two_doubles =" 22145.365 -3564789";
std::string::size_type K;
double first = std::stod (two_doubles, &K);
double second = std::stod (two_doubles.substr(K));
}
The string starts with white spaces. I get this error message when compiling:
warning unused variable 'first'
warning unused variable 'second'
How do you convert the two numbers in the string two_doubles to doubles?
View 2 Replies
View Related
Dec 6, 2014
My code so far
Code:
#include <stdio.h>
#include <ctype.h>
#include <string.h>
[Code]....
I keep getting these 3 errors :
error expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|.
error expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|.
error expected '{' at end of input|.
View 4 Replies
View Related
Nov 29, 2014
What happens if I make a server application using tcp protocol and then establish connection with a client application but the server crash and then the client send data. Will the data be lost or the system will continue trying to send it?
View 2 Replies
View Related
May 9, 2012
I want to create an application that starts an application and passes input to that application. I know how to start a process using the classes in System.Diagnostics, but I don't know how to pass data to the process.
For example, and this is just an example, I would like to be able to automatically start an application that requires a username and password and automatically enter the username and password. Of course, that might open the door to security vulnerabilities, but that's not the point of the exercise.
How to implement the functionality I described? Is there a general way to go about doing this or does it depend entirely on the idiosyncrasies of the application in question?
View 2 Replies
View Related
Oct 4, 2012
i have task scheduling application which execute every 30 minute i want to keep this process when system is log off in c# console application
View 2 Replies
View Related
Apr 7, 2013
I am programming a translator, and I have it so that it detects words with spaces both in front of and behind them, so I did "string.append(space);" where space equals " ". That added a space to the end, but I still need a space added to the front.
View 1 Replies
View Related
Feb 12, 2014
I have a problem who must print the sentences who have lenght more than 20 characters. I dont know why, but it prints just the first words. Look what i made.
#include<stdio.h>
#include<conio.h>
int main()
[Code]....
For instance :
Give the number of sentences : 3
First sentence : I like the website bytes.com
Second sentence : I like more the website bytes.com
Third sentence : bytes.com
After I compile the program it should print the first two sentences.
View 2 Replies
View Related
Feb 20, 2014
Why is this
Code: fFile << (char) (i)p.x, (char) (i)p.y,(char) (i)p.z); not the same as this
Code: printf("%c%c%c", (i)p.x, (i)p.y, (i)p.z);
View 13 Replies
View Related
Jan 3, 2013
From my tests I found the problem to be somewhere in the Mantissa part that converts it to binary.
bool xsDLL GetHexFromSF_IEEE754( void* to, Text from, ui08 tSize ) {
from.UpperCase();
int db = 0, dB = 0, dBEnd = tSize, dBLast = ( tSize - 1u ), dbEnd = dBEnd * 8;
ui08 *data = reinterpret_cast< ui08* >( to );
for ( ; dB >= 0; --dB )
data[ dB ] = 0u;
[Code] ....
Adjustments made, still having problems though. After finding a more useful resource [URL] ..... I got the function looking more like it should but am still having problems...
View 1 Replies
View Related
Apr 7, 2013
I am in a c++ class and my group is having a hard time making this work... It keeps saying that 'fileOne.open' isn't working.
#include <iostream>
#include <string>
#include <fstream>
[Code]....
View 3 Replies
View Related
Nov 8, 2014
Having trouble converting char to hex.
according to here [URL] ....
ô in decimal is 147 and print ô using alt 147
and here [URL] ....
ô in dec is 244 but prints ⌠ using alt 244
put on console
char c = ô;
cout << (int)c << endl;
prints -109 and print m using alt -109
I am using alt to test char output. Why I'm getting a negative value? Which of the tables are correct? I have string of char that I want to print in hex. I get a hex string but the hex value don't correspond to any of the two tables on the websites because the console converts special char to negative values.
View 2 Replies
View Related
May 16, 2013
I am having problems with converting a CString to an int and than doing checks on the int to see if it is in a particualr range.Below is what I am doing.
CString numstr = "28"
int num = atoi(numstr);
BOOL valid = TRUE;
if(num < -32,768 {
valid = FALSE;
}
For some reason when running the above code the if statement is executed but it should not be becasue 28 is not less than -32,768. Why this is happening, I am not seeing the reason for this at all!! The num variable is being assigned the correct value.
View 5 Replies
View Related
May 18, 2014
Code:
void convertNetPay(float netPay, char *netPayString){
int numHuns, numTens, numOnes;
char OnesTable[9][8]={"One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};
char ResultString[10+1];
char TensTable[9][8] = {"Ten","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"};
char TeensTable[9][10] {"Eleven","Twelve","Thirteen","fourteen","fifteen","Sixteen","Seventeen","Eighteen","Nineteen"};
float cents;
[Code] ....
I have to convert my netpay which is a float to a string So if I input a value of say, 356.26 it should output "the sum of three hundred fifty-six and 26/100 dollars" . My program function works for the sum of three hundred but after that it spits out garbage.
View 2 Replies
View Related
Jun 3, 2014
i m trying to write a code that would convert a each letter from a text to their decimal images . while i was able to write the part of entering the text , i cant do the converting part , i searched all day on the internet and found nothing.
View 3 Replies
View Related
Oct 31, 2013
Write a program to convert the time from 24-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore your program must contain at least the following function : a function to convert the time from 24-hour notation to 12-h notation, a function to convert the time from 12-hour notation to 24-hour notation, a function to display the choices, function(s) to get the input, and function(s) to display the results.
View 2 Replies
View Related
Mar 13, 2014
I am trying to read into a file that has something like
I have 5 apples and 9 bananas.
Sam has 8 apples and 6 bananas.
and I need to replace the numbers with words. For example I need to change the "5" to five and so on. The problem is that im not sure how to access and then replace just the numbers.
#include <iostream>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main() {
ifstream in_stream;
[Code] ....
View 2 Replies
View Related
May 6, 2014
How will I add the existing content of the text file to the newly inputed date(hoursworked & minsWorked) to compute the total number of hours works. I'm just a beginner in using Visual basic C++.
Code:
#include <iostream>
#include <fstream>
#include<string>
#include <cstdlib>
using namespace std;
bool parseTime(char* _timeStr, int& _hour, int& _min) {
[Code] ....
View 6 Replies
View Related
Dec 7, 2014
I'm trying to find a way to accuratley convert a double in the form of a bank account number stored in a file into a string representing the number returned by a file.
View 1 Replies
View Related
May 18, 2014
void convertNetPay(float netPay, char *netPayString) {
int numHuns, numTens, numOnes;
char OnesTable[9][8]={"One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};
char ResultString[10+1];
[Code] ....
BASICALLY, I have to convert netpay (float to string). Theoretically if I have 666.66, my program here should output the sum of "six hundred sixty-six and 66/100 dollars".
View 4 Replies
View Related
May 2, 2013
i think i need to convert a double to a string, we are working in visual studio doing a program. when i run the calculator i'm not getting the answer i need instead its giving me 0.0 when it should be reading 0.5, here is the code i'm using
{int width;
int height;
int area;
double gop;
String ^strWidth;
String ^strHeight;
String ^strArea;
String ^strGop;
strWidth=width1->Text;
[Code]....
View 1 Replies
View Related
Jun 22, 2014
Sandy is of class Person, who converts to Muslim and takes on a new name Fatima, and has all the attributes of Sandy, with new Muslim attributes (e.g. religion == Islam, etc..). At this point, Sandy can be deleted, and Fatima, now of class Muslim will play Sandy's role henceforth. The problem is that due to her new address, all the people who knew Sandy does not know Fatima. Manually changing Sandy's address to Fatima's address for all those people who knew Sandy is clearly not an acceptable method. I looked through all the design patterns and cannot find one to solve this problem. how to improve the design? Here's my simplified code showing the problem:
#include <iostream>
#include <string>
#include <typeinfo>
class Person {
std::string name;
Person* bestFriend;
[Code]...
Output:
sandy = 0x32658, 6Person
Mary's best friend is Sandy.
fatima = 0x23fec0, 6Muslim
Mary's best friend is Sandy.
Of course, we want to have: Mary's best friend is Fatima,. with mary->getBestFriend()->getReligion() == Islam, etc... How to redesign the whole thing so that this is automated (assume there are thousands of people who know her)?
View 14 Replies
View Related