the error belongs to these lines:
#include %26lt;iostream%26gt;
using namespace std;
#include %26lt;vector%26gt;
When I compile my C++ code in linux, this error is printed: "no such file or directory",?
Maybe the setup your compiler is wrong.
patch up this codes, if you can run this then your compiler is working.
#include %26lt;iostream%26gt;
using namespace std;
int main()
{
cout %26lt;%26lt; "Hello World" %26lt;%26lt; endl;
return 0;
}
Note : your headers format is wrong, this the correct one.
#include %26lt;iostream%26gt;
#include %26lt;vector%26gt;
using namespace std; // always after all the headers otherwise you will use %26lt;vector.h%26gt; with "h" extension.
Reply:check to make sure you have those files. sometimes when folks build their linux box, the forget to install the headers for development. try doing a search for those files
Reply:check that all files and directories you are referrencing actually exist. I don't think vector is correct. read your documentation that came with the compiler.
Saturday, May 22, 2010
Please give me the C++ code to find the factorial of a number using class....?
Factorial of a number------ using class....
Please give me the C++ code to find the factorial of a number using class....?
// Homework assignment by %26lt;insert your name here%26gt;
// cryptic? How can a recursive static member function with a ternary operator be in any way cryptic?
// Like the other guy said
// the return value strictly should be declared as int
// but my compiler assumes int is what is wanted.
#include %26lt;iostream%26gt;
using namespace std;
class CFact
{
public:
static int fact(int n)
{
return n?n*fact(n-1):1;
}
};
int main(int argc, char* argv[])
{
int val;
cout %26lt;%26lt; "Factorial! pls enter number" %26lt;%26lt; endl;
cin %26gt;%26gt; val;
val=CFact::fact(val);
cout %26lt;%26lt; "Factorial=" %26lt;%26lt; val;
}
Reply:Peter K, you forgot to specify the return type for the static function:
static int fact(int n)
I really like your answer, though...it's accurate, and so cryptic that the teacher will know it can't possibly have come from Kishore. :-)
Reply:I know this is your assignment....Please try to do it yourself..
Please give me the C++ code to find the factorial of a number using class....?
// Homework assignment by %26lt;insert your name here%26gt;
// cryptic? How can a recursive static member function with a ternary operator be in any way cryptic?
// Like the other guy said
// the return value strictly should be declared as int
// but my compiler assumes int is what is wanted.
#include %26lt;iostream%26gt;
using namespace std;
class CFact
{
public:
static int fact(int n)
{
return n?n*fact(n-1):1;
}
};
int main(int argc, char* argv[])
{
int val;
cout %26lt;%26lt; "Factorial! pls enter number" %26lt;%26lt; endl;
cin %26gt;%26gt; val;
val=CFact::fact(val);
cout %26lt;%26lt; "Factorial=" %26lt;%26lt; val;
}
Reply:Peter K, you forgot to specify the return type for the static function:
static int fact(int n)
I really like your answer, though...it's accurate, and so cryptic that the teacher will know it can't possibly have come from Kishore. :-)
Reply:I know this is your assignment....Please try to do it yourself..
How can i convert code in hex or binary into c++ code?
You can't.
You can use a decompiler to take it back to assembler... and you may get one that will make an attempt to take it back to c++, but it will have no idea what names to use for pointers etc. And it won't de-optimise it for readability.
Oh, and it's reverse engineering which is against the terms of the license for the software and may well be illegal.
How can i convert code in hex or binary into c++ code?
It's really not possible. A single instruction in C++ can be up to 8 or more assembler instructions. There is no one way to decompile, most tools that attempt to do so do not produce nice code. It has no idea what variable names are either, so reading the code is a nightmare.
Reply:completely rewrite it.
Possibly.. use a decompiler.
C++ compiles into binary.
Programming languages just make it so you don't have to write your programs as a string of 1's and 0's. The computer only knows 1 and 0. Everything else is built from that.
You can use a decompiler to take it back to assembler... and you may get one that will make an attempt to take it back to c++, but it will have no idea what names to use for pointers etc. And it won't de-optimise it for readability.
Oh, and it's reverse engineering which is against the terms of the license for the software and may well be illegal.
How can i convert code in hex or binary into c++ code?
It's really not possible. A single instruction in C++ can be up to 8 or more assembler instructions. There is no one way to decompile, most tools that attempt to do so do not produce nice code. It has no idea what variable names are either, so reading the code is a nightmare.
Reply:completely rewrite it.
Possibly.. use a decompiler.
C++ compiles into binary.
Programming languages just make it so you don't have to write your programs as a string of 1's and 0's. The computer only knows 1 and 0. Everything else is built from that.
Can someone write some C code that scrolls an image?
I have no idea how to do this . Please help , ( assuming that the image is stored in a 2d array of pixels ) .
Can someone write some C code that scrolls an image?
I am not too sure, if C alone would be quite helpful, but you may try using the MFC libraries. Of course the assumption here is that you can use VC++ tool, otherwise you would not get MFC.
On a broader side, may I ask why are you trying to write this in C only. The contemporary lanugages like Java and C# have this feature built-in, and in case you are not shackled by the language, I would recommend to try these languages.
Reply:i would love 2 help..but i dont even know what a c-code is..sorry:(
hyacinth
Can someone write some C code that scrolls an image?
I am not too sure, if C alone would be quite helpful, but you may try using the MFC libraries. Of course the assumption here is that you can use VC++ tool, otherwise you would not get MFC.
On a broader side, may I ask why are you trying to write this in C only. The contemporary lanugages like Java and C# have this feature built-in, and in case you are not shackled by the language, I would recommend to try these languages.
Reply:i would love 2 help..but i dont even know what a c-code is..sorry:(
hyacinth
Can any body give c++ code for the following pattern?
- - - - - *
- - - - * - *
- - - * - - - *
- - * - - - - - *
- * - - - - - - - *
* * * * * * * * * * *
Can any body give c++ code for the following pattern?
for (int i=5; i%26gt;=0; --i)
{
for (int j=0; j%26lt;i; ++j) printf("-");
if (i!=5)
{
printf("*");
for (int j=0; j%26lt;(5-i)*2-1; ++j)
printf("%c",(i==0)?'*':'-');
}
printf("*\n");
}
- - - - * - *
- - - * - - - *
- - * - - - - - *
- * - - - - - - - *
* * * * * * * * * * *
Can any body give c++ code for the following pattern?
for (int i=5; i%26gt;=0; --i)
{
for (int j=0; j%26lt;i; ++j) printf("-");
if (i!=5)
{
printf("*");
for (int j=0; j%26lt;(5-i)*2-1; ++j)
printf("%c",(i==0)?'*':'-');
}
printf("*\n");
}
Need Help With This C++ Code?
#include "doublelist.h"
DoubleLinkedList* dl_insert( DoubleLinkedList*%26amp; list, int id )
{
DoubleLinkedList* link = new DoubleLinkedList( id );
/*
* TODO: insert the new link onto the list
*/
;
return link;
}
void dl_remove( DoubleLinkedList*%26amp; list )
{
/*
* TODO: detach the link from the list
*/
delete list;
list = 0;
}
DoubleLinkedList::DoubleLinkedList( int _id )
{
id = _id;
next = 0;
prev = 0;
}
Need Help With This C++ Code?
It's Double Linked List. What about it?
Reply:What did you need help with? There isn't anything coded in the TODO section.
DoubleLinkedList* dl_insert( DoubleLinkedList*%26amp; list, int id )
{
DoubleLinkedList* link = new DoubleLinkedList( id );
/*
* TODO: insert the new link onto the list
*/
;
return link;
}
void dl_remove( DoubleLinkedList*%26amp; list )
{
/*
* TODO: detach the link from the list
*/
delete list;
list = 0;
}
DoubleLinkedList::DoubleLinkedList( int _id )
{
id = _id;
next = 0;
prev = 0;
}
Need Help With This C++ Code?
It's Double Linked List. What about it?
Reply:What did you need help with? There isn't anything coded in the TODO section.
How can I write c++ code to dislplay number of digits if I give a number?
put the int into a string var.
get the sizeof the string var.
remember.... the size of string is one plus the exact size ;)
get the sizeof the string var.
remember.... the size of string is one plus the exact size ;)
Subscribe to:
Posts (Atom)