siddhant3s 1,429 Practically a Posting Shark

>>Sorry if I made you cry, sid, but if my post imitating your style annoyed you, imagine how your original post felt to the OP. Are you getting it now? Do you see the point?
Sorry, Nucleon. Your mission was not accomplished. You didn't made me cry but just worst. You made me angry at you. I have already pointed the differences between my posts and yours. So don't compare both the posts.

>>I don't believe in invisible people (hence the "atheist atom" symbol)
:) Thats good. BTW, as I remember my physics, you cannot see the atoms from your eyes.

>>That is absolutely ridiculous! Moderators' time is better spent telling people not to tell lies. And what about sid's original personal insults to the OP? Of course, that's okay! No reprimands for sid! He's just the greatest! Why don't you give him yet more rep? Obviously he's the kind of person that Daniweb wants!

>>That is absolutely ridiculous! Moderators' time is better spent telling people not to tell lies.
Maybe it is ridiculous to you, but I think Ancient was being himself rather than being a moderator in this thread.

>>And what about sid's original personal insults to the OP? Of course, that's
>>okay!
You are again comparing the two posts which are different.

>>No reprimands for sid! He's just the greatest!
Are your reprimands any less?

>>Why don't you give him yet more rep? Obviously he's …

siddhant3s 1,429 Practically a Posting Shark

>>If the images didn't load you would have seen it repeated for each little green dot you have.
Thanks Dani, that was an expected reply.

So were these Text Repos automated, or assigned to me by some human?

siddhant3s 1,429 Practically a Posting Shark

>>I don't have a "bright" future -- I have a "brilliant" future and I only see it once. Maybe you have a problem with your browser. I am using FF on Vista Home. IE8 also does not have that problem for me.

Must be a 'brilliant' one. I don't exactly remember but just the gist.
Do you know is it automated or are these remarks were given manually.

Personaly, I still like those green dot instead of those Textual Repos!! Go green :)

siddhant3s 1,429 Practically a Posting Shark

Thats a 100X50 matrix. Means that the array should be of 5000 elements.
If I we assume that each int takes 4bytes, that makes 20000 bytes nearly equal to 20Kilo Byte.
Anyways, here is what you can do.
1. Create an array of 5000 elements. say int arr[5000]
2. Read the text file character by character to a char variable. say char c
3. Run a loop through the file and read the file charactrer by character to c.
4. Store the c-'0' to the current i-th postion in the array.
5. Increment i, go to step 3

siddhant3s 1,429 Practically a Posting Shark
siddhant3s 1,429 Practically a Posting Shark

>>I see that you are only in the rough just once. So you must have gotten out of the rough a couple times
Not really. I am just in rough once in a while. (actually that 'once' in the while is usually as long as change of seasons).

I also notice your Textual Reputation : "Ancient Dragon has a bright futureAncient Dragon has a bright futureAncient Dragon has a bright future"

What really amused me that it was repetitive.

siddhant3s 1,429 Practically a Posting Shark

>>The standard doesn't stop them, common sense.................................
...........position to use it judiciously.
Right and Done.
>>it looks to me like nucleon replied to you in the same tone that you replied to the
I don't think so. I never abused the OP. Moreover, Nucleon responded utter non-sense. His motto was to degrade my remarks. While, motto was to inform OP, Not to ask question like these ( Now,I don't want comments regarding whether or not it is the right Philosophy, we already had a discussion regarding). Also, his posting added to anyone's knowledge about C++.

>>The only question I can't answer conclusively .................of discussion.
Agree.

>>Not possible. Programmers are especially proud people, .....................
Good to hear that.

>>NAH-roo-way, approximately.
Oh man! this can't get so crazy of me. I was here sitting in front of my PC with everyone around in my room. I followed the link and tried to pronounce your name. After trying about 15-20 times repetitvely, I noticed that everyone was looking at me with their Big eyes. And then my dad asked " What's the matter son, is everything ok?" and I said "Of course dad".
I although is still not perfect to pronounce your name, but I think I am close to it.
If you ever had time, try to post a MP3 file of your pronunciation.

Hemsworth>>Good post Narue.
Yeah , It really was a good one.

So when …

siddhant3s 1,429 Practically a Posting Shark

Hey, I saw some textual reputation here on Dani for short period some minutes ago.
"siddhant3s is a jewel in roghsiddhant3s is a jewel in roghsiddhant3s is a jewel in rogh"

Yeah, it was repeated many times.
Then I checked that some text reputation was assigned to everyone!!
Whats that.
Why it got removed.

siddhant3s 1,429 Practically a Posting Shark

Of course your previous demand will preclude the beginners from learning anything by crushing their inquisitive spirit. They won't reach the point where everything clears up and will either leave the field or become one of those bad programmers we all fear will join our team.

It seems we have opposite philosophies on learning. I believe that all questions should be answered completely. If a student has reached the point where he knows enough to ask the question, he knows enough to be given an honest answer rather than tripe about how he's too inexperienced to "get it".

Good.
Narue, I think it was me the first who tried to satisfy OP by giving at least a logical explanation (rather than that 'giving more control to the programmer' logic) [It doesn't prove anything]
But what annoyed me really was the reply of Nucleon. Seriously, that took my nerves apart.
Your philosophy may be right. But can you (or anyone here around) seriosly answer that question? I could just get OP close to real thing because I just told him what was on Stroustrup's Homepage.
As Ancient said, only a member of ISO committee ( of perhaps some of their close friends) can really answer that.

PS: How can we discuss these things without spoiling the thread? I really feel very sorry when we discuss ( or fight) here. On the other hand, these discussions are important too.
PPS: Of topic- How do I pronounce …

siddhant3s 1,429 Practically a Posting Shark

To the Ancient Dragon:
I wrote in post #33:
>>I replied too quickly.
Bjarne states that standards doesn't stops the implementors to reset the pointer just deleted to NULL

Do you agree?
Or am I in some wrong misconception?
I researched and found that it is true that C++ standards doesn't stop compiler writer to reset the deleted pointer to null.
http://www.research.att.com/~bs/bs_faq2.html#delete-zero

siddhant3s 1,429 Practically a Posting Shark

void main is a crime. Always use int main. http://cppdb.blogspot.com/2009/02/should-i-use-void-main-or-int-main-or.html

if( day=0) will always be true. Use if(day == 0) instead. There is a difference between = and ==. The former is an assignment operator. The later is a logical operator, it evaluates whether the LHS and RHS are equal or not.

I don't know julian system so I cannot help you in logic.
Another advice. Try to use more descriptive names of variables instead of a,m,y.
I cannot interpret what does these variable are created for. Use a bigger name. like current_year, current_month. It will surely need you to type more, but it will clear out your path to become a good programmer.

[edit] I was reading about julian system of date. It turns out that the variable you used a,y,m are standard variables. So sorry to intercept. But my advice should be followed in all the other program you will write.

tux4life commented: Very good !! +3
siddhant3s 1,429 Practically a Posting Shark

Just make the parameter of function of type istream and pass by reference.
Maybe an example would help:

int print_the_istream(std::istream& the_stream)
{
    if (! the_stream)
        return 0;// error, return false

    std::string buff;
    while (!the_stream.eof())
    {
        the_stream>>buff;
        std::cout<<buff;
    }
    return 1;// return true.Everything is fine
}
//usage:
int main ()
{
    std::ifstream inData;                        // Create new input file stream object
    inData.open( "aboutYou.txt" );
    if ( ! print_the_istream(inData))
        std::cout<<"Cannot read the stream";
}

[edit:]Coder++:
what are iostream.h and fstream.h? These were the old headers. ISO strictly reccoments to use fstream and iostream instead.
Your code will not work because you have not passed istream object by reference. You have passed by value.

siddhant3s 1,429 Practically a Posting Shark

Checked your program, it is running just fine.
You are asked to show that the exception handler which takes the Base class(runtime_error) as its argument can handle exception where the derived class(DevideByZeroExeption) is thrown.
This is perhaps what your instructor wants from you:

try
          {
                result = quotient( number1, number2 );
                cout << "The quotient is: " << result << endl;
          }
//note that the handler require an exception thrown of
//type 'runtime_error'. But this handler can in fact be 
//called even if we throw an error of any derived class
      catch ( runtime_error &error )
          {
                cout << "Exception occured: " << error.what() << endl;
          }
           cout << "\nEnter two integers ( end-of-file to end ) : ";
siddhant3s 1,429 Practically a Posting Shark

>>I think you guys are reading too much into the problem. It simply asks that the program keep track of the lightest and lowest values entered, there is nothing about storing all the values.

Right vmanes, even I was first thought of giving the same line of attack to the problem. But I asked him to store values in an vector so that he maybe later if decide to print the arithmetic mean, median, etc can do that with least modifying the code. Moreover, maybe this will help him get through more concepts (it is quite possible that OP didn't used a vector before).;)
Anyways, this approach ( what you gave in your last post) will surely be more fast and efficient(both memory and time) to do small jobs like this.

siddhant3s 1,429 Practically a Posting Shark

>>You make it sound as if being polite makes you a crap programmer all of a sudden.
Not at all. I am just want to point out that believing everyone who is polite, will eventually lead to beak down. (I never ever meant that it will bring out a crap programmer. My point is : politeness is got nothing to do with your programming expertise.)

>>On your first post, you could have accomplished the same without giving everybody a bad impression of you.
I think it would have gone something like this:

Oh please Hemsworth, give me some C++ knowledge if you have. I don't sit here on dani for moral education.

PS: Go and check out my posts on the other threads. you won't see 'this' me in those posts. If I was rude in this thread, it was for a reason. Only if you all guys would be more of programmers rather than 'customer care executives'

siddhant3s 1,429 Practically a Posting Shark

This is from http://www.cplusplus.com/reference/string/string/data/ about string::data:
Get string data

Returns a pointer to an array of characters with the same content as the string.

Notice that no terminating null character is appended (see member c_str for such a functionality).

So modify your code something like this:

cout << "Enter the name of the input file:";
 string inputname;
 getline(cin, inputname);
 ifstream fin;
 fin.open(inputname.c_str()); //use c_str() instead of data
.
.
.
.
.
.
 ofstream fout(outputname.c_str()); //use c_str() instead of data
.
siddhant3s 1,429 Practically a Posting Shark

Well, you may record the sound to a file. Then use some hashing algorithm ( like md5sum) to calculate the hash number of that file.
Each different type of sound will give you different files. And if two files are different, their md5sum hash will of course be different.

siddhant3s 1,429 Practically a Posting Shark

Gtk+ can be a real pain on Windows.
I got it to work after several attempts.
There is a GTK+ installer for windows available on the website.
The main problem arises, when you need to compile your GTK+ code.
My team used Code::Block IDE on windows. But we were not able to configure it so that it could compile our GTK+ code. So we used the command line( we used Msys with MinGW) to compile our program, thereafter suffer no problem.

I am not remembering the EXACT steps we took. But you will surely get it to work if you search the web.

siddhant3s 1,429 Practically a Posting Shark

You have to first create a data structure. An array or vector of int should be the most correct data structure.
Then ask the user how may value you need to input.
Run a loop and accept all those value in a vector ( or array,) from the user. ( by using cin>>)
Now you will have a vector ( or an array) which contain the sequence.
To find the maximum, assume that the first element of the vector (or array ) is the maximum. (this can be done by defining a variable: max and setting its value to the value of the first element of the vector or array) Now iterate through the whole vector(or array) and check if max<n where n is the i-th element.
If it is, set max to n.

tux4life commented: Very good description of the algorithm :) +3
siddhant3s 1,429 Practically a Posting Shark

"implementing the dereferencing operator" means overloading it for your class.
I though agree, that the OP may not referring to operator overloading.
Anyways, in that case, the Dragon has already replied.

siddhant3s 1,429 Practically a Posting Shark

In some books I read:
Elevator Simulation:: The program will simulate elevators. The user pushes a button ( by pressing a number key on the keyboard. Number indicates the floor on which he is) and then the elevator decides its path so that it could fill up requests of most of the users.
You model an elevator as an object.

siddhant3s 1,429 Practically a Posting Shark

You don't have to do this.
It will be a very nice thing if your compiler will point out the error for you. In this case it will. Just tell the user of your class that you can only templatize those classes which have the CompareTo function. This way, if user will try to pass another class as T, the compiler would raise an error. What can be good than that. Compiler has already solved your problem

siddhant3s 1,429 Practically a Posting Shark

He perhaps, meant that he wants to customize the uranary * operator ( the dereferencing operator) for is custom class.

I don't know why would you like to do that but here is what I got:
Overload dereference operator like this:

T& operator*() const //this will return some value of type T
{
return *m_ptr;//return some value of type T
}

Src: http://www.velocityreviews.com/forums/t450268-overloading-global-dereference-operator.html

siddhant3s 1,429 Practically a Posting Shark

I replied too quickly.
Bjarne states that standards doesn't stops the implementors to reset the pointer just deleted to NULL

C++ explicitly allows an implementation of delete to zero out an lvalue operand, and I had hoped that implementations would do that, but that idea doesn't seem to have become popular with implementers.

siddhant3s 1,429 Practically a Posting Shark

Oops, I didn't meant that?
I meant the data pointed by that pointer.
Sorry,
I will just edit it

[edit]
I replied too quickly.
Bjarne states that standards doesn't stops the implementors to reset the pointer just deleted to NULL

siddhant3s 1,429 Practically a Posting Shark

First of all my apologies for being out the thread for a while. I had my exams today. Just finished that and thus replying so late. Because of the exam I was not able to stay up last night.( remember I am +5.5hrs GMT).
I read all the posts after I tried to conclude this thread in post #16. But then too, the thread did not concluded hence I am making the second effort.

To the OP: C++ was designed to allow the programmer to have nearly full control over what's happening in the program. Automatically assigning a pointer to NULL once it's been deleted is a waste of cpu, as once deleted, it's usually not used again until it's been reassigned.

This is not actually the answer. Or if you stick to it, it is the answer to every problem in C++. Saying that a feature X has been added to 'get more control in the language' is no answer. I agree though, that automatically assigning a pointer to zero is a waste of cpu time.

Besides causing many other problems, here is an obvious reason not to.

This reason is not different from what I gave. But obviously this is not an obvious reason.
>>buffer = NULL; // What's the point in this line
There is of course a point in this line that the programmer wants to set buffer to zero. ( I though agree that there are very non-obvious cases where this …

siddhant3s 1,429 Practically a Posting Shark

>>*Deleting a pointer to null is undefined behavior. But it is a bad bad practice.[edit] Sorry it is a defined behavior. deleting a pointer to null won't do anything to the pointer. C++ guarantees this. http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.8
[/edit]

siddhant3s 1,429 Practically a Posting Shark

Useful link, thanks.
So, for the benefit of anyone else who didn't get that code, the point is that resetting p to NULL can be pointless since it is easily circumvented by copying the pointer.
Also interesting to see in that link that Bjarne says the standard doesn't prevent compilers from doing the reset (for lvalues) and he had hoped that more implementations would take this approach.

Good to know now your getting on it. Phew.
Note that even though Stroustrup is father of C++, his job is not to write compilers. He may hope that implementors will do it someday but you may fail to think that it is not an easy job for the implementors
For the time being, just create your own function.

To summarize:
*Deleting a pointer to null is undefined behavior. But it is a bad bad practice.
[edit] Sorry it is a defined behavior. deleting a pointer to null won't do anything to the pointer. C++ guarantees this. http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.8
[/edit]
*Deleting a pointer twice is an udefined behaviour too.(though you may argue me that it gives you an error on your compiler) and is implementation dependent. Not to mention it is too a bad practice.
*Reseting to Null by delete is certainly not a good idea.
*(Sply to nucleon) Trying to be a hero(whose knowledge is doubtable) is certainly not a good idea.
*Being sympathetic to OP may be nice, …

siddhant3s 1,429 Practically a Posting Shark

>>Nothing would happen!
Just check on your part. You mean if compiler doesn't complain, everything is OK?
These are few of the undefined behaviors which means ( Effective C++ by Mayers gives a good info about Undefined behaviors) "anything can happen".
Or in other words it is implementation dependent.

>>! Are you a mindless idiot? Did your brain fall out? Did you replace it with a turd you found on the ground?
Answer to all these (useless) question is NO.

>>Answer: a complete and total moron, i.e., siddhantes!!! The OP's question was about the REASONING (something sid cannot comprehend) of the designers.

You are no one to judge my comprehension.

>>Don't worry about the "sidiot," as we shall call him. He has serious personality problems. Just ignore anything he says.
That was not funny. It was not in the same zipcode, funny.
I have a lot of other problems rather than dealing with my personality. Specially, I hate when people speak without having adequate knowledge.

>> Everybody else does!
Give me at least 5 names plz.

>>(P.S. The tone of the above is entirely contingent on the sidiot's original tone.)
May be, but my post was not as useless your is.

siddhant3s 1,429 Practically a Posting Shark

>>Seems a bit hard on the OP. He/she was just asking to be educated. Is that a problem?
Not at all. I have done my job.

>>
As for your code, I hope the OP does get it, but I'm afraid I don't.
Calling delete on p deallocates it and, at the request of the OP, sets P to NULL. How does that affect q? q still contains a pointer to the memory which has been deallocated. Calling delete q after delete p is always doomed to failure whether p was cleared or not.
<<
According to the standards, the behavior is undefined (that means the consequence can be from a simple error to the crash of the machine) and is implementation dependent.

>>
Not trying to be difficult. I genuinely don't see what you're trying to illustrate
here.
<<
You would if you wanted ( and not trying to be over-sympathetic ). I am trying to satisfy OP that this behavior of delete has a reason. But on the same time I am suggesting the OP, not to ask such questions relating to (why the hell this )standards ( is applied) . ( If you have a doubt and you feel that there is an error in the standard, bring a solution out)

>>
Please educate me - but be nice eh...
<<
You mean polite? Well sure, but not in the next 3 …

siddhant3s 1,429 Practically a Posting Shark

A general swap algorithm is :

//say you want to swap var1 and var2
temp= var1;
var1=var2;
var2=temp;

In c++ you can use the ready made function std::swap() defined in <algorithm> header file which can do this job for you.

//    swaps the content of m-th element of a vector vec, with the
//    n-th element of the same vector
std::swap(vec[m],vec[n]);
siddhant3s 1,429 Practically a Posting Shark

Yeah, if you really want a feature like that you might have to implement it yourself: Create a new pointer datatype and overload the delete operator for it in such a way that the pointer is always set to NULL after releasing the allocated memory :) ...

If really wanted to things like this, I would simply create a (templatized) function like this

template<class T> 
inline void destroy(T*& p) 
{ 
    delete p; 
    p = 0; 
}

But the fact remains that these things( my function hack or your overloaded pointer hack or any other such things) will lead to error like I pointed.
Also note what happens when I use this destroy function like this:

int* f();//some function returning a pointer.
	int* p;//some pointer pointing to some memory.
	// ...
	destroy(f());	// error: trying to pass an rvalue by non-const reference
	destroy(p+1);	// error: trying to pass an rvalue by non-const reference
siddhant3s 1,429 Practically a Posting Shark

>>Why didn't the C++ standard also have the delete operator reset ptr to NULL?
First of all you are simply **NO ONE** to ask question like this. C++ standards have been made by the most proficient and experienced programmers of this language. If you think there should be a feature added doesn't means it should be added. A boon to you may be disaster to others. C++ standards have to keeps everyone in mind.

If you really feel that everyone is dumb and delete should really reset the pointer to null answer this:
Lets say I have the following code. Just check what would happened if delete would reset the pointer to zero:

int * p=new int;
int *q=p;// q points to same memory as p
delete p; //deleting p and setting it to zero
delete q;// Shit ! deleting pointer to null 0

Got that!!
So before opening the mouth and say "Mommy I want this candy" try to think how costly( or perhaps dangerous) that candy would be. Even if you can't think how costly it is, just trust your mother that she did a good thing by not buying you that candy.

mrnutty commented: A little harsh don't you think? And deleting a null pointer is allowed. And your code does not prove any point. -1
siddhant3s 1,429 Practically a Posting Shark

>>but when i use the delete keyword .. it gives me a heap corruption detected debug error

delete an array using delete[] and not just delete.

void Card::setFirstName(){
	char* inputFirstName = new char;
	cout << "\n\nEnter First Name - ";
	cin >> inputFirstName;
	firstName = inputFirstName;
	cout << firstName;
	delete[] inputFirstName;
}
siddhant3s 1,429 Practically a Posting Shark

>>char* userData = "\0";
Seeing this? This tels the compiler to allocate 2bytes to userData, So if your user enter text more than one character, you're doomed.
Better change to this:

const int MAX=20;
char userData[MAX];

I am smelling that you are using an old compiler. If not, why not using std::strings?

siddhant3s 1,429 Practically a Posting Shark

Look, I coded the function myself and it is working great;
I will give you the code of the encrypter to get you started, you should write the decrypter yourself:

void CaesarEncrypt(char word[],int key,int size)
{
    for (int i=0;i<size;i++)
    {
        if (word[i] >='A' && word[i] <='Z')
        {
            int OV=word[i] + key;//overflow

            word[i]=(OV <= 'Z')? OV :'A' + (OV-'Z'-1);
        }

        if (word[i]<='z'&&word[i]>='a')
        {
           int OV=word[i] + key;//overflow

            word[i]=(OV <= 'z')? OV :'a' + (OV-'z'-1);
        }

    }
}
siddhant3s 1,429 Practically a Posting Shark

>>Oh, he meant it like that, he only wants to count the elements which aren't zero I assume then ?
No Tux, He wants to magically find out how many elements he changed in the array.
(Read the whole thread, I know it is not easy though. This is the worst part of Usenet ;))

siddhant3s 1,429 Practically a Posting Shark

>>And what if you consider the following ?
Tell me if this work:

int array[5]={1,23};
//this var will still tell you 5 while the OP wants 2
int element_count = sizeof(array)/sizeof(int);
siddhant3s 1,429 Practically a Posting Shark

>>Yes you're right, but I think Ancient Dragon actually wanted to simplify it for the OP
This was not required Tux, (I was sensing it right) It is not right for OP to know that he doesn't know

siddhant3s 1,429 Practically a Posting Shark

>>I think you should send the argument "word" as a reference and not copies of the argument.
He is passing a pointer actually.

>>the encryption function is working fine, but I'm having troubles with the decryption.
Even Encryption is not good. Here is the output:

siddhant3s@Xion:~/Documents$ ./testofcallbyreference
Enter the word please:
mathematically
Please enter the key
5
Enter "e" to encrypt, "d" to decrypt
e
rf_mjrf_nhfqqd

So, what is the error?
I think you may have guessed.
Check if the Resultant character exceeds 'z' or 'Z' , If it does do the needfull

siddhant3s 1,429 Practically a Posting Shark

>>There are several free compilers, such as Code::Blocks, Dev-C++, and VC++ 2008 Express.
( Note to OP: I am talking to Ancient Dragon, this has got nothing to do with you)
I never knew Code::Blocks and Dev-C++ are compilers!! I thought they were IDEs ;)
Or am I sensing it right?

tux4life commented: Absolutely right :) ! +2
Ancient Dragon commented: good observation :) +36
siddhant3s 1,429 Practically a Posting Shark

RAND_MAX is a constant defined by your implementation ( i.e. it is defined by what compiler are you using on what platform) is a large number but it is at least 32767(it may be greater depending on your implementation)
rand() function generates a random integer between 0 and RAND_MAX
For more :http://www.cplusplus.com/reference/clibrary/cstdlib/rand/

siddhant3s 1,429 Practically a Posting Shark

To generalize:
:: stands for scope resolution operator( I know you know this) which has two operand : the scope[1] and the object/function.
When you don't write the scope explicitly ( like ::gcd() ) it means you are referring to the global scope.

[1] Scope can be a Class or namespace.

siddhant3s 1,429 Practically a Posting Shark

>>Edited the code, try again,
Sorry, OP is right. x[100]={1,2,3,0,3,5,4,1}; will print 2 elements

To the OP:
You cannot !. Yes you cannot. However surprise it may bring to you, the truth is you really you cannot.
Thats why most of functions dealing with int array often asks you to enter the length of the array as one of the argument.
You will have to track the length of the array yourself.

Edit: Niek, I don't know why I couldn't see you editing, but the fact is that my "viewing list" at the bottom of page told me that no one was replying to the thread while I was.

siddhant3s 1,429 Practically a Posting Shark

>>initialize static member function
>>initializing a function

These two things doesn't mean anything in C++. You don't initialize a function. You initialize an object ( or a variable, whatever you call them).
Things you can do with functions are:
Declare them
Define them
Call them
Overload them
Templatize them
May be more but I just cannot think of them right now.

There is no thing as initializing a function (or member function)

siddhant3s 1,429 Practically a Posting Shark

>>I initialize the matrix as following and when then I cout, the program crashes..
Look at the <endl it should be <<endl
Are i and j defined?
Try running this code on your compiler;

int matrix[512][512];
   for(int i=0;i<512;i++){
	   for(int j=0;j<512;j++){
		  
		   matrix[i][j]=-1;
	   }
	   }

cout<<matrix[100][100]<<endl;
siddhant3s 1,429 Practically a Posting Shark

Your solution is posted as the announcement of DaniWeb : We only give homework help to those who show effort
This is what it reads:

This forum is meant for discussing programming languages in addition to exchanging code and algorithms. However, it has become a problem where too many students are posting homework problems expecting a quick solution without ever trying for themselves. Not only does this constitute cheating, but it is very discouraging, frustrating, and annoying to everyone who takes valuable time to answer programming support questions.

Though we are all here to help, please don't expect quick solutions to your homework. We'll help you get started, exchange algorithm ideas, how-to's, etc. but only if you show that you're willing to put in effort as well.

siddhant3s 1,429 Practically a Posting Shark

>>The happy end: that damned structure definition is public now.
This was one of the trivial solution. I was looking forward to do something 'good'(like forward declaration). Alas, it didn't worked.

>>Moral of a story: a modular programming considered harmful...
Are you sure?

siddhant3s 1,429 Practically a Posting Shark

>>The last question: where is Modular Programming in OP snippet?
You're with me. Lets open a new thread and discuss it !! LOL
(This means that even I don't know where does Modular Programming comes into play)

siddhant3s 1,429 Practically a Posting Shark

>>do I have to define the structure globally?
No just declare it globaly. Like this

struct ROPES;
int fillStruct (ifstream& fin, ROPES ropes[], int n);

int main()
{
struct ROPES
{
members
};
return0;
}

int fillStructs (ifstream& fin, ROPES ropes[], int n)
{}