|
could anybody plz tell me that how to convert a string value to double or a string to its corresponding ascii value in vc++???
|
|
|
|
|
Nehathoma,
It seems like you are struggling with data conversion for past few days. Here is a list of data conversion routines that I copy pasted from MSDN. May be you can find answers to your future queries also from the table below.
Data-Conversion Routines : msdn [^]
abs Find absolute value of integer <br />
atof Convert string to float <br />
atoi, _atoi64 Convert string to int <br />
atol Convert string to long <br />
_ecvt Convert double to string of specified length <br />
_fcvt Convert double to string with specified number of digits following decimal point <br />
_gcvt Convert double number to string; store string in buffer <br />
_itoa, _i64toa, _itow, _i64tow Convert int to string <br />
labs Find absolute value of long integer <br />
_ltoa, _ltow Convert long to string <br />
_mbbtombc Convert 1-byte multibyte character to corresponding 2-byte multibyte character <br />
_mbcjistojms Convert Japan Industry Standard (JIS) character to Japan Microsoft (JMS) character <br />
_mbcjmstojis Convert JMS character to JIS character <br />
_mbctohira Convert multibyte character to 1-byte hiragana code <br />
_mbctokata Convert multibyte character to 1-byte katakana code <br />
_mbctombb Convert 2-byte multibyte character to corresponding 1-byte multibyte character <br />
mbstowcs Convert sequence of multibyte characters to corresponding sequence of wide characters <br />
mbtowc Convert multibyte character to corresponding wide character <br />
strtod, wcstod Convert string to double <br />
strtol, wcstol Convert string to long integer <br />
strtoul, wcstoul Convert string to unsigned long integer <br />
strxfrm, wcsxfrm Transform string into collated form based on locale-specific information <br />
__toascii Convert character to ASCII code <br />
tolower, towlower, _mbctolower Test character and convert to lowercase if currently uppercase <br />
_tolower Convert character to lowercase unconditionally <br />
toupper, towupper, _mbctoupper Test character and convert to uppercase if currently lowercase <br />
_toupper Convert character to uppercase unconditionally <br />
_ultoa, _ultow Convert unsigned long to string <br />
wcstombs Convert sequence of wide characters to corresponding sequence of multibyte characters <br />
wctomb Convert wide character to corresponding multibyte character <br />
_wtof Convert wide-character string to a double <br />
_wtoi, _wtoi64 Convert wide-character string to int or __int64 <br />
_wtol Convert wide-character string to long
suhredayan There is no spoon.
|
|
|
|
|
hai friends any body help me in my problem?i want to convert my string to double or to ascii?can any one give code for that?pls..
shan
|
|
|
|
|
Someone posted working string to double code before, then deleted the post, I guess they realised their question was non-existant.
This code requires you to include cstdlib.
char *stop = 0;
char * testvar="123.4";
double x=strtod(testvar, &stop);
What do you mean by string to ASCII ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi All,
I have an application which uses automation to prepare a Word Document....
When i am placing the text i want to obtain the width that it would occupy with the selected Font and Size...
I have tried using GetTextExtent but the value that i get seems to be incorrect (thats visible from the output i get).
I have the Font size in points and the required width in Twips ....
So please suggest how can i achieve this by using a self created DC, i do ot want to depend on any Window ( my app is console based )..
Thanks and Regards,
ashwinder
|
|
|
|
|
ashwinder wrote:
I have tried using GetTextExtent...
You are on the right track but without seeing exactly how you are doing it, it's hard to say.
ashwinder wrote:
...but the value that i get seems to be incorrect (thats visible from the output i get).
How are you verifying the results?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello,
I am working with VC++ 6.0 (MFC).
Normally an ActiveX control is binding with an application
exe) dynamically. We need to ship the "ocx" file with the "exe" file, for distribution.
My question is :
Is there any way to bind the "ocx" statically with the "exe" so that I can distribute the "exe" alone?
TIA,
Regards,
Jahfer V P
|
|
|
|
|
Jahfer V P wrote:
Is there any way to bind the "ocx" statically with the "exe" so that I can distribute the "exe" alone?
AFAMK to avoid the OCX file and get its functionality in your application, you will have to get the source code from the OCX vendor and include in you project. But this also may not be possible if the ocx and ur application are developed in different languages.
suhredayan There is no spoon.
|
|
|
|
|
The idea of OCXs is that they are seperate.
I suggest using an installer to create an install disc and make sure it has the OCX as part of the installation.
I have done simple installations with InstallShield that came with VC++6.0 Enterprise and this collected the OCXs automatically from the project.
I'm sure that others can advise you on current packages that would suit your needs.
Elaine
The tigress is here
|
|
|
|
|
Hi All,
I stuck with a small problem in RichEditControl.My Requirement is i have a dialog box.I need to add a button naming UNDO.i have done some operations(copy,paste,delete) on RichEditCtrl placed on that Dialog,If i pressed that UNDO button the last change should be undone.This is my Requirement.
I Used Like this:
if(richeditobj.CanUndo())
{
richeditobj.Undo())
}
For me CanUndo is not returning Correct return Value.
Thanks in Advance
Aravind
If you have faith in the cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
|
I am currently working out a project using Digital Gates, we've done the implementation of the circuit and the results will all ok. But there was a problem that i am facing currently, my Digital Gates will always disappear when i minimize or maximize the screen of my program.
I know that i can use CWnd::UpdateWindow to refresh the screen, but i do not know how and also what are the parameters and arguments should i add in?
Can anyone guide me through this difficult stage thank you.
From: Guilbert
|
|
|
|
|
popo84 wrote:
my Digital Gates will always disappear when i minimize or maximize the screen of my program.
you have two solution to this problem :- either create your window with CS_SAVEBITS Class style which make your drawing on screen persistent! (look for more detail about above property in RegisterClass documentation)
or Handle WM_PAINT message to draw your Image Every Time the Windows Refreshes. also you can manually refresh your window by using CWnd::Invalidate()
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
But i did not use WM_PAINT, i created my own Function with parameters
Below is what i created:
void ShowBitmap(int x, int y, int Gate)
{
CDocument* pDoc = GetDocument();
CClientDC dc(this);
CBitmap bitmap;
CDC dcMemory;
BITMAP bm;
switch (kind) {
case AND :
bitmap.LoadMappedBitmap(IDB_AND,0);
break;
case NAND :
bitmap.LoadMappedBitmap(IDB_NAND,0);
break;
case OR :
bitmap.LoadMappedBitmap(IDB_OR,0);
break;
case NOR :
bitmap.LoadMappedBitmap(IDB_NOR,0);
break;
case NOT :
bitmap.LoadMappedBitmap(IDB_NOT,0);
break;
case XOR :
bitmap.LoadMappedBitmap(IDB_XOR,0);
break;
case XNOR :
bitmap.LoadMappedBitmap(IDB_XNOR,0);
break;
case DLR :
bitmap.LoadMappedBitmap(IDB_DLR,0);
break;
case SLR :
bitmap.LoadMappedBitmap(IDB_SLR,0);
break;
case _1TO2LR :
bitmap.LoadMappedBitmap(IDB_1TO2LR,0);
break;
case UD :
bitmap.LoadMappedBitmap(IDB_UD,0);
break;
case UL :
bitmap.LoadMappedBitmap(IDB_UL,0);
break;
case UR :
bitmap.LoadMappedBitmap(IDB_UR,0);
break;
case DL :
bitmap.LoadMappedBitmap(IDB_DL,0);
break;
case DR :
bitmap.LoadMappedBitmap(IDB_DR,0);
break;
case LT_ON:
bitmap.LoadMappedBitmap(IDB_LT_ON);
break;
case LT_OFF:
bitmap.LoadMappedBitmap(IDB_LT_OFF);
break;
case _DEL :
bitmap.LoadMappedBitmap(IDB_EMPTY,0);
break;
case START :
if(kind==START)
m_dStart.DoModal(); //popup dialog box
if (m_dStart.StartValue==0)
bitmap.LoadMappedBitmap(IDB_START0,0);
else
bitmap.LoadMappedBitmap(IDB_START1,0);
//UpdateData(FALSE);
break;
case END :
bitmap.LoadMappedBitmap(IDB_END,0);
break;
default : break;
}
bitmap.GetObject(sizeof(BITMAP),&bm);
dcMemory.CreateCompatibleDC(&dc);
dcMemory.SelectObject(&bitmap);
dc.BitBlt(x,y,bm.bmWidth,bm.bmHeight,&dcMemory,0,0,SRCCOPY);
}
|
|
|
|
|
Now Simple Draw the Bitmap using this piece of code
void <your class>::OnPaint()
{
this->ShowBitmap(x,y,Gate);
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi Again thanks for your help
Next Step what should i do?
From: popo84
|
|
|
|
|
Hi again i already follow your instruction and putting
this->ShowBitmap(x,y,Gate);
but got some errors:
c:\Documents and Settings\Administrator\My Documents\My Received Files\Jingpo work\E-learn_ruler_gate_SDObject\E-learn\E-learnView.cpp(1347): error C2144: syntax error : 'int' should be preceded by ')'
c:\Documents and Settings\Administrator\My Documents\My Received Files\Jingpo work\E-learn_ruler_gate_SDObject\E-learn\E-learnView.cpp(1347): error C2660: 'CElearnView::ShowBitmap' : function does not take 0 arguments
c:\Documents and Settings\Administrator\My Documents\My Received Files\Jingpo work\E-learn_ruler_gate_SDObject\E-learn\E-learnView.cpp(1347): error C2059: syntax error : ')'
Thanks for your help really
From: popo84
|
|
|
|
|
popo84 wrote:
Hi again i already follow your instruction and putting
this->ShowBitmap(x,y,Gate);
is ShowBitmap is member of view class
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Yes it is a member of the View Class and just want to tell you that our View Class is being change to ScrollView
From: Guilbert
|
|
|
|
|
I just started learning how to use C++ and I have a program problem. I thought that I completed the program correctly, but it keeps saying that I have errors, and I don't know why. Below I have what the program is about and my code.
About the program: AG Enterprises has sales outlets in 5 different regions numbered from 1 to 5. Write a program that calculates and displays the total amount sold in each region. Use a counter-controlled while loop to count the regions. Use a nested while loop to allow the user to enter the sales for a given region. Output the total sales for the region as soon as the inner loop stops.
My code:
#include <iostream>
using std::cout;
using std::endl;
int main()
{
double sales = 0.0;
double totRegSales = 0.0;
for (int region = 1; region < 6; region = region + 1)
{
cout << "First sales amount for Region" << region << ":";
cin >> sales;
do
{
totRegSales = totRegSales + sales;
cout << "Second sales amount for Region" << region << ":";
cin >> sales;
} while (sales > 0);
do
{
totRegSales = totRegSales + sales;
cout << "Third sales amount for Region" << region << ":";
cin >> sales;
} while (sales > 0);
do
{
totRegSales = totRegSales + sales;
cout << "Fourth sales amount for Region" << region << ":";
cin >> sales;
} while (sales > 0);
do
{
totRegSales = totRegSales + sales;
cout << "Fifth sales amount for Region" << region << ":";
cin >> sales;
} while (sales > 0);
cout << "Region " << region << "sales: " << totRegSales <
|
|
|
|
|
There are no errors, this code compiles fine, assuming the #include is iostream.
do
{
totRegSales = totRegSales + sales;
cout << "Second sales amount for Region" << region << ":";
cin >> sales;
} while (sales > 0);
This code has me confused - you're saying that the user needs to keep entering a sales value until they enter 0. Is that really what you want, to force the user to always enter zero ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
no i don't want the user to keep entering zero, do you have any suggestions? and i think it is include iostream, right?
|
|
|
|
|
Get rid of the stupid while loop, or reverse it if you want to stop zero being entered.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Atptour wrote:
...but it keeps saying that I have errors...
Care to share them with us?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi, You've not implemented it as required in the program specs.
The specs say five regions, numbered 1 to 5 but don't say anything
about how many outlets are in each region.
Secondly they ask for an out "counter controlled while loop" : you have
implenented a "for" loop.
Thirdly they ask for a nested while loop to handle sales outlets.
You have (probably incorrectly) assume five outlets per region
and implemented five seperate while loops, one for each assumed outlet
and each of which will only accept zero (or a negative number) as a
sales amount (if sales > 0 the loop will keep asking until zero or
less is entered)
In the absense of a defined number of outlets per region you'll
have to allow the user to end the input (for that region) by
for example entering a zero amount.
You should also probably get used to using the use c++ incrementers
e.g.
Outlet++; and
RegionSales += Sales;
instead of
Outlet = Outlet + 1; and
RegionSales = RegionSales + Sales;
So the final code snippet will be something like :
(untested)
int Region;
int Outlet;
double RegionSales;
double Sales;
Region = 1;
while ( Region <= 5 ){
cout << "Region " << Region << endl;
Outlet = 1;
RegionSales = 0.0;
do {
cout << "Enter sales for outlet" << Outlet << " (enter 0 for next region) : " ;
cin >> Sales;
RegionSales += Sales;
Outlet++;
} while (Sales != 0.0);
cout << "Region " << Region << " sales total : " << RegionSales << endl << endl;
Region++;
}
cout << "End of Program" << endl;
Steve T
|
|
|
|