I was doing this program on Visual Studio 2005 where the program converts C to F and vise versa but after debugging it, it doesnt give the expected result. Could someone tell me what is wrong with my code???
#include %26lt;iostream%26gt;
#include %26lt;iomanip%26gt;
using namespace::std;
using std::fixed;
int main()
{
int conversionType = 0;
double temp = 0.0;
double result = 0.0;
cout %26lt;%26lt; "Enter -1 (F to C) or 2 (C to F): ";
cin %26gt;%26gt; conversionType;
cout %26lt;%26lt; "Enter temperature: ";
cin %26gt;%26gt; temp;
if (conversionType == '-1')
{
result = (temp - 32) * 5 / 9 ;
}
else if (conversionType == '2')
{
result = temp * 9/5 + 32;
} //end if
cout %26lt;%26lt; "Result: " %26lt;%26lt; result %26lt;%26lt; endl;
return 0;
} //end of main function
--------------------------------------...
C++ programming question?
I'm not a c++ programmer but if your converstionType is an integer, why are you comparing it to a string? (conversionType == '2').
Reply:what the hell? ? Report It
Reply:what the hell? ? Report It
Reply:You're comparing the integer "conversionType" to a character in each of your if statements. Remove the quotes.
Reply:You are not pausing the prompt so that it can show the output. Add one of these
system ("PAUSE");
cin.ignore();
cin.get();
above return 0.
I use Dev C++, so I use system ("PAUSE"). You use something else, so these commands may not work. If they don't, then this definitely will.
It will hold the session until the user presses a key and since there is no more code after it, it will close the window.
Also, remove the quote or else it will return 0 regardless of what you put in.
#include %26lt;iostream%26gt;
#include %26lt;iomanip%26gt;
using namespace::std;
using std::fixed;
int main()
{
int conversionType = 0;
double temp = 0.0;
double result = 0.0;
cout %26lt;%26lt; "Enter -1 (F to C) or 2 (C to F): ";
cin %26gt;%26gt; conversionType;
cout %26lt;%26lt; "Enter temperature: ";
cin %26gt;%26gt; temp;
if (conversionType == -1)
{
result = (temp - 32) * 5 / 9 ;
}
else if (conversionType == 2)
{
result = temp * 9/5 + 32;
} //end if
cout %26lt;%26lt; "Result: " %26lt;%26lt; result %26lt;%26lt; endl;
char t;
cout%26lt;%26lt;"Press a key to end the session";
cin %26gt;%26gt; t;
return 0;
} //end of main function
Saturday, May 22, 2010
Building a "Hello World" DLL using the Microsoft C++ compiler.?
Can anyone help me write a "Hello World" DLL console app. using MS C++ compiler ? Without using the Visual Studio .NET IDE.
(It seems to be next to impossible getting a simple answer for that question, by trawling the web)
Building a "Hello World" DLL using the Microsoft C++ compiler.?
Here are the steps:
1. Open the Visual Studio 2005 Command Prompt window. Note: The Visual Studio 2005 Command Prompt automatically sets up the correct path to the Visual C++ compiler and any needed libraries, so it is used instead of the regular Command Prompt window.
2. At the command prompt, type notepad and press Enter. In notepad select the File menu and save the file as hello.cpp and press Enter.
In Notepad, type the following lines:
#include %26lt;iostream%26gt;
using namespace std;
int _tmain()
{
cout%26lt;%26lt; "Hello World!! " %26lt;%26lt; endl;
return EXIT_SUCCESS;
}
3. On the File menu, click Save. You have created a Visual C++ source file. On the File menu, click Exit to close Notepad.
4. At the command line prompt, type cl /EHsc /LD hello.cpp and press Enter. The /EHsc command line option instructs the compiler to enable C++ exception handling while the /LD option sets the file output to a .DLL file.
Look in the folder where the hello.cpp file was saved and you will find a hello.dll file.
Reply:I'm not sure what you mean. Do you want a console app, a DLL, or a console app that calls a DLL?
A console app is simple. A DLL is a bit more work. I've never called a DLL from a console app, so I would have to check if that's even possible. Let us know what it is that you're trying to do.
Reply:just open a project ... write :
void main()
{
printf("Hello world");
}
and you are done
order flowers
(It seems to be next to impossible getting a simple answer for that question, by trawling the web)
Building a "Hello World" DLL using the Microsoft C++ compiler.?
Here are the steps:
1. Open the Visual Studio 2005 Command Prompt window. Note: The Visual Studio 2005 Command Prompt automatically sets up the correct path to the Visual C++ compiler and any needed libraries, so it is used instead of the regular Command Prompt window.
2. At the command prompt, type notepad and press Enter. In notepad select the File menu and save the file as hello.cpp and press Enter.
In Notepad, type the following lines:
#include %26lt;iostream%26gt;
using namespace std;
int _tmain()
{
cout%26lt;%26lt; "Hello World!! " %26lt;%26lt; endl;
return EXIT_SUCCESS;
}
3. On the File menu, click Save. You have created a Visual C++ source file. On the File menu, click Exit to close Notepad.
4. At the command line prompt, type cl /EHsc /LD hello.cpp and press Enter. The /EHsc command line option instructs the compiler to enable C++ exception handling while the /LD option sets the file output to a .DLL file.
Look in the folder where the hello.cpp file was saved and you will find a hello.dll file.
Reply:I'm not sure what you mean. Do you want a console app, a DLL, or a console app that calls a DLL?
A console app is simple. A DLL is a bit more work. I've never called a DLL from a console app, so I would have to check if that's even possible. Let us know what it is that you're trying to do.
Reply:just open a project ... write :
void main()
{
printf("Hello world");
}
and you are done
order flowers
Free C++ program for mac?
is there a free C++ program like the microsoft visual studio?
if so, where can i get it
Free C++ program for mac?
You can get it by throwing away that piece of junk and buying a real computer.
Reply:XCode comes on your installation disc, or as a free download from the apple developer site (requires registration). Of course, it doesn't include the Microsoft Foundation Classes, but it does have the Cocoa and Aqua frameworks.
if so, where can i get it
Free C++ program for mac?
You can get it by throwing away that piece of junk and buying a real computer.
Reply:XCode comes on your installation disc, or as a free download from the apple developer site (requires registration). Of course, it doesn't include the Microsoft Foundation Classes, but it does have the Cocoa and Aqua frameworks.
Can anyone recommend a Code Review tool for C# ?
I am looking for a Code Review tool for C# that
1. Integrates with Visual Studio 2005
2. Allows you to easily add custom rules
3. Doesnt cost a mint !
The main need for this tool is to ensure that our developers adhere to our Microsoft Coding Standards and our own specific set of standards.
So far I have come across:
* FxCop - only works on assemblies and is difficult to customise
* Code Analysis for Visual Studio Team Edition - too expensive
* SSW Code Auditor - trial version seems buggy
The following site is the best I have found for simialr tools but none really meet the criteria:
http://sharptoolbox.com/categories/code-...
Any help would be greatly appreciated.
Seamus
Can anyone recommend a Code Review tool for C# ?
pinkworld.com
desipapa.com
worldsex.com
etc
Reply:I really did not Know
1. Integrates with Visual Studio 2005
2. Allows you to easily add custom rules
3. Doesnt cost a mint !
The main need for this tool is to ensure that our developers adhere to our Microsoft Coding Standards and our own specific set of standards.
So far I have come across:
* FxCop - only works on assemblies and is difficult to customise
* Code Analysis for Visual Studio Team Edition - too expensive
* SSW Code Auditor - trial version seems buggy
The following site is the best I have found for simialr tools but none really meet the criteria:
http://sharptoolbox.com/categories/code-...
Any help would be greatly appreciated.
Seamus
Can anyone recommend a Code Review tool for C# ?
pinkworld.com
desipapa.com
worldsex.com
etc
Reply:I really did not Know
Anyone Looking For a Graphic Artist in South Florida?
If you are looking for a diverse candidate in marketing %26amp; graphic design to see projects from beginning to end, look no further…
My background includes:
• Marketing – SEO, PPC, and online Marketing %26amp; Advertising Campaigns
• Graphic Design – Print, Photography, Web %26amp; Multimedia Design
• Copy Editing
• Software Knowledge: PhotoShop, Director, QuarkXpress, DreamWeaver, Illustrator, FreeHand, Fireworks, Premiere, InDesign, AfterEffects, ImageReady, CorelDraw, FrontPage, PageMaker, Streamline, Acrobat, Microsoft Office Suite (Word, PowerPoint, Publisher, Excel, Outlook, and Access), Microsoft Visual Studio (Visual InterDev, Visual Basic, Visual C++), 3D Studio Max, AutoCAD, QuickTime, Microsoft IE and Netscape
I am available for fulltime or freelance work. Please email me for my résumé, references and portfolio examples.
Anyone Looking For a Graphic Artist in South Florida?
You can post free ads on the following sites:
http://www.craigslist.org
http://www.backpage.com
http://www.oodle.com
Good Luck!! Also post ads in your local laundry facilities and grocery stores. Place where people are frequently visting.
Enjoy your month!!!
$$$$$$
My background includes:
• Marketing – SEO, PPC, and online Marketing %26amp; Advertising Campaigns
• Graphic Design – Print, Photography, Web %26amp; Multimedia Design
• Copy Editing
• Software Knowledge: PhotoShop, Director, QuarkXpress, DreamWeaver, Illustrator, FreeHand, Fireworks, Premiere, InDesign, AfterEffects, ImageReady, CorelDraw, FrontPage, PageMaker, Streamline, Acrobat, Microsoft Office Suite (Word, PowerPoint, Publisher, Excel, Outlook, and Access), Microsoft Visual Studio (Visual InterDev, Visual Basic, Visual C++), 3D Studio Max, AutoCAD, QuickTime, Microsoft IE and Netscape
I am available for fulltime or freelance work. Please email me for my résumé, references and portfolio examples.
Anyone Looking For a Graphic Artist in South Florida?
You can post free ads on the following sites:
http://www.craigslist.org
http://www.backpage.com
http://www.oodle.com
Good Luck!! Also post ads in your local laundry facilities and grocery stores. Place where people are frequently visting.
Enjoy your month!!!
$$$$$$
How to open an Excel file in a C++ MFC application?
This might be too complicated a question to expect much help on Yahoo! Answers, but here's hoping...
I have an MFC application in Visual Studio 2005 (I'm using C++) and I need to open an Excel spreadsheet and read fields
(for example, A1 to A5) and then write to fields (for example, B1 to B5).
How do I do this? What includes do I need, and do you have an example of how this would work?
Thanks to you all!
How to open an Excel file in a C++ MFC application?
Here's a step by step tutorial:
http://support.microsoft.com/?kbid=30840...
spring flowers
I have an MFC application in Visual Studio 2005 (I'm using C++) and I need to open an Excel spreadsheet and read fields
(for example, A1 to A5) and then write to fields (for example, B1 to B5).
How do I do this? What includes do I need, and do you have an example of how this would work?
Thanks to you all!
How to open an Excel file in a C++ MFC application?
Here's a step by step tutorial:
http://support.microsoft.com/?kbid=30840...
spring flowers
How do I link a .DLL into my C program on windows.?
I am using microsoft visual studio platform to run my c code.I am calling some functions which are available in a DLL.
How do i link that DLL into my C code so that i can use functions from that DLL.
How do I link a .DLL into my C program on windows.?
If you have the corresponding .LIB file for your DLL, just link that file with your project and declare functions in your C/C++ code using dllimport (or include header file if it comes with the library):
http://msdn2.microsoft.com/en-us/library...
If you don't have .LIB file, you do it manually using LoadLibrary() / GetProcAddress():
typedef VOID (*MYPROC)(LPTSTR);
...
MYPROC pFunction;
HINSTNCE hDLL = LoadLibrary("file.dll");
...
pFunction = (MYPROC) GetProcAddress(hDLL, "MyFunctionFromDLL");
The following MSDN article will help:
http://msdn2.microsoft.com/en-us/library...
How do i link that DLL into my C code so that i can use functions from that DLL.
How do I link a .DLL into my C program on windows.?
If you have the corresponding .LIB file for your DLL, just link that file with your project and declare functions in your C/C++ code using dllimport (or include header file if it comes with the library):
http://msdn2.microsoft.com/en-us/library...
If you don't have .LIB file, you do it manually using LoadLibrary() / GetProcAddress():
typedef VOID (*MYPROC)(LPTSTR);
...
MYPROC pFunction;
HINSTNCE hDLL = LoadLibrary("file.dll");
...
pFunction = (MYPROC) GetProcAddress(hDLL, "MyFunctionFromDLL");
The following MSDN article will help:
http://msdn2.microsoft.com/en-us/library...
Subscribe to:
Posts (Atom)