Thread: Segmentation fault in my program

  1. #1
    Registered User Dr.JacKaL's Avatar
    Join Date
    Oct 2014
    Posts
    2

    Post Segmentation fault in my program

    Hey guys I'm new here & new to C Programming too, I have a problem with a little program I made that calculates the product of two matrices. Any thoughts are appreciated.
    Segmentation fault in my program-ex9-1-jpg

    And here is the error I get:

    Segmentation fault in my program-ex9-gcc-jpg
    Thanks a lot guys.

  2. #2
    Registered User
    Join Date
    Sep 2007
    Posts
    1,012
    The condition in line 29 (i < n) is wrong; neither i nor n changes in the loop, so the result will always be the same. Presumably you meant to use "k", not "i".

  3. #3
    Registered User Dr.JacKaL's Avatar
    Join Date
    Oct 2014
    Posts
    2
    Quote Originally Posted by cas View Post
    The condition in line 29 (i < n) is wrong; neither i nor n changes in the loop, so the result will always be the same. Presumably you meant to use "k", not "i".
    Yes Thanks a lot

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,121
    You really shouldn't be developing code and surfing the web logged in as root.
    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.

  5. #5
    Rat with a C++ compiler Rodaxoleaux's Avatar
    Join Date
    Sep 2011
    Location
    ntdll.dll
    Posts
    203
    The way root is protected in unix, just getting in scares me. I feel like if I went to the wrong thing, a virus would transcend my computer, infect my central nervous system and take control of me
    How to ask smart questions
    Code:
    DWORD dwBytesOverwritten;
    BYTE rgucOverWrite[] = {0xe9,0,0,0,0};
    WriteProcessMemory(hTaskManager,(LPVOID)GetProcAddress(GetModuleHandle("ntdll.dll"),"NtQuerySystemInformation"),rgucOverWrite,5,&dwBytesOverwritten);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple program has segmentation fault??
    By fsi in forum C Programming
    Replies: 4
    Last Post: 12-04-2011, 10:25 AM
  2. CS 1 Program segmentation fault but can't see the problem
    By DaNxTh3xMaNx in forum C Programming
    Replies: 1
    Last Post: 09-29-2010, 08:23 PM
  3. Segmentation fault on my program
    By blackswan in forum C Programming
    Replies: 2
    Last Post: 05-11-2005, 04:47 PM
  4. Segmentation fault in beginning or program
    By tameeyore in forum C Programming
    Replies: 1
    Last Post: 02-26-2005, 08:16 PM
  5. Segmentation fault !, program works:S
    By jspri in forum C Programming
    Replies: 8
    Last Post: 09-28-2004, 05:25 PM