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.
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;
I have a problem with converting a C++ string into a long double. In order to do this, I used the function strtold, but the result I get is only the integral part, that is: if for example the input string is 12.476, I only get 12 as the converted long double value. This happens with atof too.
Here is my code:
#include <stdio.h> #include <stdlib.h> #include <string> #include <sstream> string test = "12.345"; long double test_longd = strtold(test.c_str(),NULL);
I'm having some trouble with a variable from a database. That variable in that database is of type double.
To read from the database, I'm using a variable dr of type OleDbDataReader.
So far, I've been using dr["variablename"].ToString() to work with the variables from this database - without the ToString part it wasn't working.
However, with this specific variable (I'll call it "var"), I have to do numerical comparisons of >= and <=, so obviously, just using dr["var"].ToString() doesn't work.
Therefore, I tried creating a variable of type double called varConv and setting it as
That doesn't work, gives me an error message saying "Input string was not in a correct format". If I remove the ToString part, it also doesn't work, with a different error message saying "Object cannot be cast from DBNull to other types".
Trying to do a direct comparison, as in dr["var"] >= x also doesn't work, says "Operator '>=' cannot be applied to operands of type 'object' and 'int' ".
I have int pointer called p and i want to calculate average.Since average involves using double or float so i am trying to convert this in the function averagetemp. It still gives me an error saying "cannot be converted"...
#include <iostream> using namespace std; int* createArray(int n); int lowesttemp(int *p,int f); int highesttemp(int *p,int f); double averagetemp(int *k,double f); void print(int *p,int lowest_temp,int highesttemp,int average_temp);
I am trying to write a Fraction class and getting the following warning when compiling my code :
Fraction.cpp: In constructor 'Fraction::Fraction(double)': Fraction.cpp:8: warning :converting to 'int' from 'double'
My Fraction.cpp class looks like :
#include "Fraction.h" Fraction::Fraction(int n, int d):num(n),den(d) { cout << This is double param constructor <<endl; } Fraction::Fraction(double d):num(d),den(0)
I can't figure out how to load multiple lines. I tried using , but I can't get it to work. Is there a better way of doing it than I am right now? This is my code.
char message[100]; int messageCount = 0; for(unsigned int i = 0; i < file.size(); ++i) { message[i] = file[i];
Am I assigning something the wrong way? Also, I am trying to avoid using array notation in order to practice, at least for the assigning of the strings.
This code i made is a cent converter from 5 to 95 cents. The problem i'm receiving is when the 'cents' function is sent back to the 'main' function it only prints one line. It seems to just print the first if construct that complies with the statement. Is there anyway i can have this function print multiple cent values? For example if 60 cents was entered it would only print '50c', and i want it to print '50c' and '10c' instead.
Code:
#include <stdio.h> int x; void check(int x) { if( x < 5) printf("Less then 5 cannot be calculated "); else if(x > 95)
I am trying to make a messageBoxButtons dialog with the 'yes, no' buttons. Im having trouble because of the multiple lines and parameters already in the message, this means that when i declare the messageBoxButtons.YesNo and the title - it throws an error because of the multiple lines etc...
How can I get the yes/no message box to work in this instance?
class Output { string text; { DialogResult dialogResult = MessageBox.Show("Please make sure the following information is correct before submitting." + " Date: " + Date + " Hours worked: " + Hours + " Hourly rate: $" + Rate
I am writing a pure C based win32 applications. I have drawn line. Now i want to translate that line, move the line whereved user wants to move on screen. Then again I drawn another line, I am drawing multiple lines.
I have created rectangle region for each line and trying to move the line.
When I move the 2nd line over the 1st line on screen the 1st line is getting wiped out. Because I am InvalidateRect() of the rect for the line being moved, so when that rectangle is crossing the other line then the other line is getting removed from the screen.
How can I rectify it. How can I have all the lined being on the screen and moved according to the user's wish. The code should be pure C and win32 no MFC.
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() {
error expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|. error expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|. error expected '{' at end of input|.
I'm trying to remake my Windows screensaver written with C++ and WinAPIs to work on multiple monitors. I found this article that gives the basics. But when I implement it in my own code, I get a weird result. Take a look at this code:
Painting always works on a primary monitor. But when I paint to the secondary monitor, I can only paint directly to its DC. When I use double-buffering technique (with DIRECT_PAINT pre-processor directive commented out) I only get a black screen on a secondary monitor when it should've been red.
First one with direct painting that works:
and then the one that doesn't, with double-buffering technique:
I need making a function that is deciphering multiple strings from a .txt file. The function is supposed to remove all instances of the first three characters from the string.
An example would be from l.pjkjsdfl.p[)sdfslkl.p ------> jkjsdf[)sdfslk
Basically it removes "l.p" from wherever it is in the string.
I am new to C++ and I don't know where to start from.