why do i get a bug?

This is a discussion on why do i get a bug? within the C Programming forums, part of the General Programming Boards category; when i run the following code, i think I get an overflow problem, why? Any help would be great Code: ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    10

    why do i get a bug?

    when i run the following code, i think I get an overflow problem, why? Any help would be great

    Code:
    /*Inverses.c*/
    #include <catam.h>
    
    main()
    {
      int i,j;
      int store[1][11];
      for (j=0;j<11;j++){
        store[1][j]=j;}
      for (j=0;j<11;j++){
        printf("%d", store[1][j]);}
        return 0;
    }

    0 [main] inverses2 1692 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
    51213 [main] inverses2 1692 open_stackdumpfile: Dumping stack trace to inverses2.exe.stackdump

    Process inverses2.exe exited abnormally with code 101120

  2. #2
    Registered User
    Join Date
    Feb 2003
    Posts
    16
    you have defined a two dimentional integer array with one row and 11 columns.
    Array index starts from 0 to <arraymax
    so, you should use store[0][j] instead of store[1][j]
    Code:
    /*Inverses.c*/
    #include <catam.h>
    
    main()
    {
      int i,j;
      int store[1][11];
      for (j=0;j<11;j++){
        store[0][j]=j;}
      for (j=0;j<11;j++){
        printf("%d", store[0][j]);}
        return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Zooming Algorithm Bug
    By stuffy_boiz in forum C Programming
    Replies: 2
    Last Post: 01-19-2009, 02:34 AM
  2. gaks bug?
    By Yarin in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-31-2008, 03:47 PM
  3. Debugging a rare / unreproducible bug..
    By g4j31a5 in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 08-05-2008, 01:56 PM
  4. Another link from Microsoft about bug in fread
    By vart in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 05-06-2008, 12:56 PM
  5. ATL bug of CComPtr?
    By George2 in forum Windows Programming
    Replies: 6
    Last Post: 04-07-2008, 08:52 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21