|
If I do something like the following:
#define<br />
#include "XYZ.h"<br />
using namespace XYZ;<br />
#undef
I get the following error:
error C2007: #define syntax
I get that error withour without the using namespace statement as well.
Is that what you meant or was it something else?
|
|
|
|
|
Hi All,
I am new in c++, I want to draw a simple graph between two values using c++, Can anyone help me. ?
Mareo
|
|
|
|
|
|
Guys I also have the algorithm see if this helps! THanx alot!
Input & Output~~~
The user will enter
1 for a triangle
2 for a rectangle
or 0 to quit
Any other number is unacceptable.
Use a loop to force the user to enter a valid value
Use a menu format for a prompt
If the user enters 1 or 2, she should be prompted to read a single character that will be used to create the figure.
any keyboard character may be specified
For a triangle, the user will enter the height of the triangle.
The output is a triangle created with height representing the number of lines on the screen. For example, a height of three would look like:
*
**
***
For rectangles, the user will enter the height and width of the rectangle.
The output is a rectangle created with height representing the number of lines on the screen and the width is the number of characters on each line. For example, a height of three and a width of four would look like:
****
****
****
Main should print the total number of characters used or an error message.
Algorithm~~~~
Create a main program loop controlled by the users response in the next step
Use a menu to ask the user to select 0, 1 or 2 (quit, triangle, rectangle)
Use a call-by-reference utility function to force the user to enter a number between 0 and 2.
If the user said to quit, leave the main loop.
Otherwise
use a call-by-reference function to ask the user to enter a character to be used when displaying the figure.
Use a call-by-reference function to ask the user to enter a height and (for rectangles only) a width.
Call a function that creates the image and returns
the number of characters used to create the image
or, 0 if the image was not created
An error has occured (return 0) if
the height is less than 1 or larger than 20
the width is less than 1 or larger than 40
This function must call another function to create one line of the image
main should check the value returned
Print the number of characters used
say something if an error occurred (zero return value)
|
|
|
|
|
|
Every Body can do that, but they have their ovn application to make. This is soooooo Simple even you can do it. Have you readed any tutorial or any Book on c++. They give you some basic enogh to make that simple app. If you need a tutorial on managed c++ you can finde it
here:
http://www.functionx.com/managedcpp/index.htm[^]
Don't you even know how to start? If you do, then just start and try to program with some brain.
|
|
|
|
|
Guys Iam an amatuer in C++ language. I need help with this program. Please if anybody can help me with it. Please write a code for me. Its a simple program but I dont know how to do it. Please its really important for me to do this stuff! THanks alot!
I have the output to how this program looks and Iam supposed to write a code for this. Please help me out buddies!
Here is the link to this Program output please download it and change the extension to .EXE . THankx alot guys! Waiting for early reply!
LINK~~~~http://www.megaupload.com/?d=6QQALGT9
|
|
|
|
|
Hi, I have a problem validating with a XmlValidatingReader and a .xsd file
the validation breaks when the importDate attribute is parsed
< Info importDate = "1967-08-13" />
in the .xsd is defined as
< xs:attribute name="importDate" type="xs:date" use="required" />
and the error message is
"The 'importDate' attribute has an invalid value accordint to its data type. An error occurred at, (12, 44)"
Anyone has an idea why this happens, when I validate the same XML file in the XMLSpy it works fine, then i run my program and it breaks in that line, if I remove the line then everything works
Thanks in Advance
Isaac B
|
|
|
|
|
hello,
I inherited C/C++ source code with a lot of precompiled defines depending on the product to compile for. A lot of these defines are also nested. So changing the software for one product is difficult as the code is not really readable. Placing the new code between the wrong defines implies wrong functioning of other products afterwards.
Does anyone knows an editor in which I can define which defines are used so that I only see the code that is used ?
stoffel
|
|
|
|
|
How to change CEdit's background color and text color? thanks.
|
|
|
|
|
Hi All,
Thanks in advance.
I am not able retrieve the out parameter values from an SQL Server stored procedure using ADODB::_CommandPtr. It is working fine with Oracle stored procedure.
The code..
ADODB::_ConnectionPtr m_objConn;
ADODB::_CommandPtr m_objCmd;
_variant_t vtEmpty1(DISP_E_PARAMNOTFOUND, VT_ERROR);
_variant_t vtEmpty2(DISP_E_PARAMNOTFOUND, VT_ERROR);
_bstr_t bstrSP("sp_MyTestSP");
_variant_t vtValue;
_variant_t vtName;
m_objConn.CreateInstance( __uuidof( ADODB::Connection ) );
m_objCmd.CreateInstance( __uuidof( ADODB::Command ) );
m_objConn->Open(lpszCnnStr, lpszUserName, lpszPwd, NULL);
m_objCmd->ActiveConnection = m_objConn;
m_objCmd->CommandText = bstrSP;
m_objCmd->CommandType = ADODB::adCmdStoredProc;
m_objCmd->Parameters->Refresh();
m_objCmd->Parameters->Item[_variant_t("@EmpId")]->Value =_variant_t((long)10);
objTable.m_pstRecSet = m_objCmd->Execute(&vtEmpty1, &vtEmpty2, ADODB::adCmdStoredProc);
/*check for the output paramaters*/
for(pp =1; pp < m_objCmd->Parameters->Count; pp++)
{
switch(m_objCmd->Parameters->Item[_variant_t((long)pp)]->GetDirection())
{
case 2:
case 3:
vtName = m_objCmd->Parameters->Item[_variant_t((long)pp)]->GetName();
sprintf(pszDest, "%s=", (LPCSTR)((_bstr_t)vtName));
vtValue = m_objCmd->Parameters->Item[_variant_t((long)pp)]->Value;
if(VT_NULL != vtValue.vt)
sprintf(pszDest, "%s%s", pszDest, (LPCSTR)((_bstr_t)vtValue));
break;
default:
break;
}
}
This code works fine with oracle stored procedures. But i am getting NULL when i use it with SQL Server stored procedures.
What could be the problem? Please help me.
Shyju.
|
|
|
|
|
Hello I am trying to draw a box and a message in a console window like so:
**************
* *
* Hello name *
* *
**************
Instead it looks like this:
**************
* *
* Hello name
* *
**************
This is my code that I am trying to get work:
<br />
int main(int argc, char *argv[])<br />
{int r=1,row=0,col=0,c=1;<br />
string name,greet;<br />
<br />
cout << "Please enter your name";<br />
cin >> name;<br />
greet = " Hello " + name +" ";<br />
<br />
row = 5;<br />
col = greet.size()+2;<br />
<br />
for(r=1;r<6;r++){<br />
for(c=1;c<=col;c++){ <br />
if(c==1 || r==1 || r == 5 || c==col)<br />
cout<< "*";<br />
else if(r==3 && c>1 && c<col-1) {<br />
cout<<greet;c+= greet.size();}<br />
else<br />
cout<<" ";<br />
}<br />
<br />
cout<<endl; }<br />
<br />
system("PAUSE");<br />
return EXIT_SUCCESS;<br />
}<br />
The top one should be a box and the second one should be a box but missing an asterisk right after name.
|
|
|
|
|
You need to change your line
c += greet.size();
to
c += greet.size() - 1;
since you've already advanced to position 1 and you want to only add the size of greet , you must subtract one from greet 's size.
"we must lose precision to make significant
statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Thanks, the program is working perfectly now.
|
|
|
|
|
Glad to hear it. Have fun programming!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi all. Thanks for listening...Well, reading i mean.
Anyway, I want to develop a console application in vs 2003 that has the looks and visual functions of the turbo c compiler.
What i mean is that i want an application in the console that has a main menu, scroll bars etc...(I dont want to develop a compiler(for god's sake))
But i have a series of critical problems:
- I cant "tell" my program whether i want it to be text screen mode 25x80 or 40x80 (is there any command or function for that?)(Personally i prefer it 25x80)
- I want it to run by default as a full screen ms dos and not as a window
- I try to draw a "window" that takes the whole screen like this one:
╔═════════╗
╚═════════╝
with characters
but printing and printing, i finally get to the last place of the last line of the last column.Printing the last character the typical commands like cout produce an end line and i lose the first line.
I want some advice on how to do such a thing as a console window.
- I want to add mouse support
- I want to add multilanguage support
Anyone who thinks he knows something or is thinking of something about it please share it.
Remember i am using VS 2003 .net
Also i dont know if programming in win32 console or .net console has many functional differences
Thank you
|
|
|
|
|
Hi, I have the following lines of code that fail once the function GetNodeContent returns "0", how can I differentiate the S"0" and the null value 0??? since a S"0" for me would mean that the status node has a S"0" value, and 0 would mean that the node wasnt found, however if the attribute is found with a "0" value the code breaks
if ((temp = GetNodeContent(nav, "/Comprobante/@status")) != 0)
this->Status = temp;
else
throw new Exception("Field required");
//*************
String* CFD::GetNodeContent(XPathNavigator *nav, String *expression)
{
XPathExpression *expr = nav->Compile(expression);
XPathNodeIterator *iterator = nav->Select(expr);
String *s;
while (iterator->MoveNext())
{
s = iterator->Current->Value;
}
return s;
}
Thanks in advance
Isaac B
|
|
|
|
|
Use NULL if you use managed C++ extension, and nullptr if you use C++/CLI.
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
You should set s to 0 to begin with: String *s = (String*)0; Or String *s = NULL;
The string "0" and the value 0 are two totaly different things. If a pointer to the string "0" is returned, you have a pointer to a valid address (which is not 0). If value returned is 0 then you have a pointer to address 0x00000000, which is an invalid address.
String *s = GetNodeContent(...);
if( !s ) {
}
INTP
Every thing is relative...
|
|
|
|
|
Having got used to typing public static in C#, I tried writing the same in C++/CLI and sure enough, the compiler gave an error. Instead of changing it to
public:
static ...
I mistakenly modified it to static public instead. Surprisingly, it compiled fine. Examining the IL using Reflector showed that it had no effect, the method was private.
Is this a compiler bug or am I missing something?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
i would go to the bug direction... what compiler did you use to try this ??
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
This was written in VC++ 2005 Express Edition, so it must be using the VC++ 8.0 compiler.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I know how to use winAPI to get the current drive contents with no problem but I am trying to write a shell program that will work on all operating systems.
Does anyone know how i can gather the drive contents of the current drive using just the standard C functions? No API and no MFC.
This is my first dos/shell command prompt program, please excuse my dumbness I am used to using API functions for everything.
Thanks for any suggestions or pointing me in the right direction.
|
|
|
|
|
You could use the CRT functions _findfirst and _findnext .
Regards,
Nish
|
|
|
|
|
Hmm.. I find your question interesting! I think you don't understand the meaning of API and/or the nature of C/C++. C/C++ is just a language. It is just a means of "using" an API. So to answer your question, there is no actual function that you could be sure would be supporting by any operating system in order to get the file structure. This is why for your case to be realistic you should start by making a list of the operating systems you would like your application to support. Only after that you can try to find a function that is supported on all of those systems (such as the _findfirst, _findnext functions the Nishant suggested). And for the operating systems that don't support those functions (in case ther will be any) you will have to provide the functions yourself.
|
|
|
|