Inanna, you sound very familiar to someone.
Grunt 19 Junior Poster
andor commented: yup you're right (andor) +2
Inanna, you sound very familiar to someone.
And please for god sake choose a better subject.
See this
#include <iostream>
using namespace std;
int main ()
{
int counter=0;
int largest=0;
int number=0;
largest=number;
while ( counter < 10 )
{
cin>>number;
if(largest<number)
largest = number;
++counter;
}
cout<<"Largest Number:"<<largest;
return 0;
}
when you declare a char it is automatically taken as signed char
That's machine dependent. It could be signed or unsigned.
Search through this forum. You'll get number of such threads.
@n3st3d_l00p
If you want a portable solution then you can use Boost Filesystem library. There's a create_directory function for creating directories.
how to create from input?
string folder;
getline(cin, folder);mkdir(folder); ???
cannot compile!
Through Command Line
#include <iostream>
#include <direct.h>
int main(int argc, char** argv) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " [new dir name]\n";
return(EXIT_FAILURE);
}
if (mkdir(argv[1]) == -1) { // Create the directory
std::cerr << "Error: " << strerror(errno);
return(EXIT_FAILURE);
}
}
What is the ICE?
Is it related to C++ and TCL communication somehow?
ICE is a Tcl compiler. The compiler translates Tcl code into C code, which can then be compiled together with a special Tcl library to produce a single executable.
I think we lost track of the question...
Very common situation in forums :)
Do you have anything more specific please.
I meant you can implement algorithms for
1) Deadlock Prevention
2) Deadlock Avoidance
3) Deadlock Detection etc.
You can choose specific area out of them or implement all of them if your project needs to be big.
Could he use something like
static_cast<int>(string[0]) - 48
I think you should avoid casts as much as possible unless there's no option left or it turns out to be less evil then the other option.
Instead of double use long long.
Only if he's using C or C99 to be more specific.
This is because of the size limitations of data types.
an int is only 4 bytes...and has a range from -2,147,483,648 to 2,147,483,647
A double uses 8 bytes (and some floating point algorithm that is beyond my comprehension at the moment) and has a range from +/-1.7E-308 to +/-1.7E308.
Your number simply went out of the range of an integer.
Interestingly enough...integers will simply loop through thaie cycle...i.e. if the number is larger than 2,147,483,647 it will restart the count at -2,147,483,648...whild doubles that exceed their upper limit will cause an error.
Don't make any assumptions about size of types. Standard only guarantees minimum sizes.
If sum is declared as double
Why would you declare sum as double in first place?
You can use long and it's variations.
sum is declared as an int, for the same range it reports -1270505460.
If int( or any other type) cannot accomodate the data then results are unpredictable.
You can implement deadlock related algorithms. I think that'll be interesting.
Compile your code in strict mode. I guess it should be error. Anyways return value in C on x86 is generally eax
, where the result of the last calculation often happens to be placed. Maybe that's why you are seeing this result.
Try using an global variable instead of passing one
Ssshhhhh...
Predict the output of the following code:
#include < IOSTREAM >
After removing spaces the header will work as long as you are working on windows which has case-insensitive file system. But, with a cross-platform compiler, usually, case matters.
Add this before switch
char letter;
cin>>letter;
SO YOU WILL NOT HELP NEWBIES:sad:
NEWBIES SHOULD NOT BE LOOKING FOR SUCH COMPLEX PROGRAMS. THEY SHOULD RATHER CONCENTRATE ON BASICS OF CRYPYOGRAPHY AND LANGUAGE IN WHICH THEY WANT TO IMPLEMENT THE PROGRAM:!:
I Want that beatle555 should
first show some efforts before asking help in forums.
Pls Help Yourself!!
Anyone will be glad to give you hand if you show your efforts here.
If you don't really know how to work with files then I would suggest you to read you book first or go through basic tutorial like
File I/O in C
File I/O in C++
Standard also has
gets()
andgoto
, too. And when you're driving, the brake doesn't have to be used at a red light.Bad practices are bad practices, even when they are allowed. The C standard also allows this program to compile and run:
I was simply highlighting that it's legal to call in C.
main( ) is just another function in C . Nothing special about it except the return type and parameter list. Though I am not encouraging anyone to call main( ) but you just can't say that it's a bad practise just like that without giving any reason.
There are lot of things like goto
, void *
etc whose use is discouraged by lot of people but there can be cases where they can come handy and be used. Even Stroustrup says that goto and void* can be useful in some cases. You can't just blindly say that these are bad practises. Basic problem is that people are ignorant and really don't know where and how to use them properly.
The code is fine and should work. Try rebuilding solution.
And you should never call
main()
in C either.
But standard doesn't stops anyone.
Why would compiller give an error? That's a valid program.
and I think unsigned long double
is anyway wrong.
I think you can use shifting
and bitwise
operators.
Look up c_str()
function.
dsraju, there's no such thing as far in ANSI C. I guess you are still using ancient compilers. It's time to move ahead.
DO you really think I should use VC2005, I mean, compared to the VC++6.0 enterprise version, the free version seemed much less powerful
Check out the features in VC2005. If they suit your requirements then download it.
If you are not so fussy about using only microsoft products only then you can download other free compilers also like Code::Blocks
There's already one in code snippet
http://www.daniweb.com/code/snippet87.html
Try to learn something from it.
If you want error checking then I would suggest you to use Exception Handling. That will be a better option.
You can use istringstream
std::istringstream stm;
stm.str("3.14159265");
double d;
stm >>d;
It's a pretty simple algorithm. Didn't you find anything about it in your algorithm's book?
You can start from here
http://en.wikipedia.org/wiki/Kruskal's_algorithm
That depends on the code.
See Wolfpack's signature...
Ah, now I get it.
He recently changed the signature but this tip came before that :mrgreen:
What does this mean? Is this an inside joke?:cry:
Even I am not sure what he meant but I didn't ask because that would have spoiled his fun :D