CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003

    Re: Error: Identifer "result" is undefined

    Quote Originally Posted by tmcfadden View Post
    Here's what this program does.

    When I run it it hits the INPUT function and waits for input. Even though the program does not prompt the user to enter something, I tested it by entering integers.
    First I entered 1, which allowed me to enter it four times before performing a calculation and returning some obscure values.
    I then entered all 2's, which allowed me to enter 13 times before performing a calculation and returning some obscure values.
    Finally, I entered 3's which allowed me to enter 34 times before performing a calculation and returning some obscure values.

    What I can tell is that it creates and array and does "something" with the numbers, after which is places them in a grid.
    But, I can't tell for the life of me what. There's no rhyme or reason to the output.
    Time to learn to use your debugger. It will show you exactly what your program is doing and why. That's what any of us would do and it's absolutely indispensable. You cannot write working programs without it. It's not optional.

  2. #17
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012

    Re: Error: Identifer "result" is undefined

    There's always 'rhyme and reason' to what a program does based upon the code it executes (unless you have a faulty CPU or compiler, which has a probability so close to 0 it can be discounted). The computer, when executing the program, does exactly what it has been told to do - no more and no less. If the program produces output which is at variance with what is expected then either the expectation is wrong or the program is at fault. In your case, you seem to have no knowledge of what the program is supposed to do! So your first step is to look at the program code and walk through it with the debugger as needed and deduce what is its function. You are correct that it performs operations on matrices - but what's that got to do with network socket programming?? If you look at the Input function, you can see that the first number requested is for the number of arrays to be used. Then for each array, it requests the number of rows and the number of columns and then inputs a value for each for these rows and columns. Then repeats for the next array etc.

    This should help to make it more clear for you as to the input it requires.

    void Input(int &numsMtrx, Mtrx *Mtrx)
    int	i,
    	cout << "How many matrices :";
    	cin >> numsMtrx;
    	cin.ignore(1000, '\n');
    	for(i = 0; i < numsMtrx; i++) {
    		cout << "How many rows for matrix " << i << ": ";
    		cin >> Mtrx[i].numRows;
    		cin.ignore(1000, '\n');
    		cout << "How many columns for matrix " << i << ": ";
    		cin >> Mtrx[i].numCols;
    		cin.ignore(1000, '\n');
    		for(j = 0; j < Mtrx[i].numRows; j++) {
    			for(k = 0; k < Mtrx[i].numCols; k++) {
    				cout << "Value for matrix " << i << " column " << k << " row " << j << ": ";
    				cin >> Mtrx[i].array[j][k];
    				cin.ignore(1000, '\n');
    Now you just have to determine what the other functions do (by inspecting the code, walking through it and using the debugger) and then you'll know what the program is supposed to do and what the output means! None of us knows by simply looking at the code what it is supposed to do. We would have to do the same as you and walk through it and use the debugger. A knowledge of matrix mathematics would also be useful!
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.7.4)

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.