Grunt 19 Junior Poster

Inanna, you sound very familiar to someone.

Grunt 19 Junior Poster

And please for god sake choose a better subject.

Grunt 19 Junior Poster
Grunt 19 Junior Poster

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;
}
Grunt 19 Junior Poster
StuXYZ commented: nice library, thx +3
Grunt 19 Junior Poster

OS and Compiler?

Grunt 19 Junior Poster

when you declare a char it is automatically taken as signed char

That's machine dependent. It could be signed or unsigned.

Grunt 19 Junior Poster

Search through this forum. You'll get number of such threads.

Grunt 19 Junior Poster

@n3st3d_l00p
If you want a portable solution then you can use Boost Filesystem library. There's a create_directory function for creating directories.

Grunt 19 Junior Poster

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);
 }

}

Grunt 19 Junior Poster

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.

Grunt 19 Junior Poster

Read the rules of the forum Rati.

Grunt 19 Junior Poster

I think we lost track of the question...

Very common situation in forums :)

Grunt 19 Junior Poster

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.

Grunt 19 Junior Poster

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.

Grunt 19 Junior Poster

Instead of double use long long.

Only if he's using C or C99 to be more specific.

Grunt 19 Junior Poster

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.

Grunt 19 Junior Poster

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.

Grunt 19 Junior Poster

You can implement deadlock related algorithms. I think that'll be interesting.

Grunt 19 Junior Poster

Look into sscanf()

Grunt 19 Junior Poster

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.

Grunt 19 Junior Poster

Try using an global variable instead of passing one

Ssshhhhh...

Grunt 19 Junior Poster

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.

Grunt 19 Junior Poster

Add this before switch

char letter;
cin>>letter;
Grunt 19 Junior Poster

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:!:

Grunt 19 Junior Poster

I Want that beatle555 should
first show some efforts before asking help in forums.
Pls Help Yourself!!

Salem commented: Salem agrees +2
Grunt 19 Junior Poster

This might help Pro*C

Grunt 19 Junior Poster

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++

Grunt 19 Junior Poster

Standard also has gets() and goto , 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.

Grunt 19 Junior Poster
Grunt 19 Junior Poster

The code is fine and should work. Try rebuilding solution.

Grunt 19 Junior Poster
Grunt 19 Junior Poster

And you should never call main() in C either.

But standard doesn't stops anyone.

Grunt 19 Junior Poster
Grunt 19 Junior Poster

Why would compiller give an error? That's a valid program.

Grunt 19 Junior Poster

and I think unsigned long double is anyway wrong.

Grunt 19 Junior Poster

I think you can use shifting and bitwise operators.

andor commented: yup you're right (andor) +2
Grunt 19 Junior Poster

Look up c_str() function.

Grunt 19 Junior Poster

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.

Grunt 19 Junior Poster

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

Grunt 19 Junior Poster

There's already one in code snippet
http://www.daniweb.com/code/snippet87.html
Try to learn something from it.

Grunt 19 Junior Poster
Grunt 19 Junior Poster

If you want error checking then I would suggest you to use Exception Handling. That will be a better option.

Grunt 19 Junior Poster

You can use istringstream

std::istringstream stm;
stm.str("3.14159265");
double d;
stm >>d;
Grunt 19 Junior Poster

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

Grunt 19 Junior Poster

That depends on the code.

Grunt 19 Junior Poster

See Wolfpack's signature...

Ah, now I get it.
He recently changed the signature but this tip came before that :mrgreen:

Grunt 19 Junior Poster

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

Grunt 19 Junior Poster

Nice tutorial. I guess it's from one of the Mod's.
http://www.shobadobs.com/tuts/big_o.html

Grunt 19 Junior Poster

You can try system function.