Thread: Why so wrong numbers? As I write so wrong?

  1. #1
    Registered User
    Join Date
    Nov 2015
    Posts
    119

    Why so wrong numbers? As I write so wrong?

    Why so wrong numbers? As I write so wrong?
    Is this better?

    Why are the numbers so wrong? How do I write that wrong?
    Is this better?


    Greetings to all friendly!

    When I try to write something yourself, there is a huge variety of errors.

    I first tried to write square vector is exactly such an array, and I got the output figures, such figures, which cannot be the multiplication table, no, these figures is not on that are not similar.

    I enclose this code. The entire project will lay out too, that would be more convenient.

    Code:
     std::vector <std::vector <int>> Tabl(1000, std::vector<int>(1000));
        for(int i=0; i<1000; i++)
            {
                for (int j=0; j<1000; j++)
                {
                    Tabl[i][j]=i*j;
                }
            }
    
         for(int i=0; i<1000; i++)
            {
                for (int j=0; j<1000; j++)
                {
                    for(int i20=0; i20<20;  i20++)
                    {
                        std::cout << Tabl[i][j] << " " ;
                        i++;
                        if(i>=1000) break;
                    }
                    std::cout << std::endl;
                }
            }
    I understand that probably need to use the start and end of the vector, but not convenient and impossible [x] [y].

    In this regard, I would very much like to see the sources of the raw vector code in exactly the same place that they would understand what happened exactly.



    Quite incomprehensible to the next. I wanted to test how nested for loops () that will be made and delivered from an ordinary array.
    And here follows the inscription "Signal SIGSEGV, segmentation default"!
    Immediately happened, none of the code does not even began to run! Wonder what happened?
    Writes an error in the address 0040E1A3 in the function _chkstk_ms (). Where you can
    Is this better?

    Greetings to all friends!

    When I try to write something myself, there are a huge number of errors.

    At first I tried to write a square vector that was exactly like an array, and I got the numbers, the numbers that could never be a multiplication table, no, these numbers don't look anything alike.

    I'm enclosing this code. The whole project will be more comfortable.



    I understand that you may need to use the beginning and end of the vector, but it is not convenient and impossible to [x] [y].

    So I'd very much like to look at the raw vector code, exactly the exact places, to understand exactly what happened.



    The following is not clear. I wanted to test how nested for loops work, which would be introduced and rendered from an ordinary array.
    And then the inscription "Signal SIGSEGV, segmentation default"!
    Immediately, no code even started to run! Amazing what happened?
    Writes an error to the 0040E1A3 address in the _chkstk_ms function. Where can
    Is this better?


    Download Z.7z from Sendspace.com - send big files the easy way

    I'm a little confused and I don't understand, please, explain the correct samples.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > int Tabl1[1000][1000];
    Well depending on the size of an int, you're looking at either 4MB or 8MB of data on the stack.

    Thread Stack Size (Windows)
    Your default stack size is 1MB.
    4 being bigger than 1 gets you an instant exception.

    The reason vectors work is because the data for vectors is stored on the heap, and only a very small structure is stored on the stack.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2015
    Posts
    119
    Thanks, thanks !! Thank you very much!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. where is my wrong reading from file and write
    By Ph0x in forum C Programming
    Replies: 4
    Last Post: 09-29-2014, 02:00 PM
  2. Replies: 1
    Last Post: 11-27-2012, 08:04 AM
  3. Replies: 2
    Last Post: 11-01-2011, 01:57 PM
  4. there's something wrong with my random numbers
    By dez in forum C Programming
    Replies: 2
    Last Post: 03-31-2010, 07:45 PM
  5. int vector outputs wrong numbers
    By Vandrian in forum C++ Programming
    Replies: 2
    Last Post: 04-03-2008, 12:15 PM

Tags for this Thread