Mac Os X Bus Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn what is bus error 10 more about Stack Overflow the company Business Learn more about hiring developers or
Bus Error 10 C++
posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Bus error: 10 on Mac OS X up vote 2 down vote favorite #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up bus error in simple Mac OSX C program up vote 1 down vote favorite I am writing a simple C program to create a twelve tone matrix. The code compiles, but I get run time error 'Bus Error'. In the http://stackoverflow.com/questions/20492056/bus-error-10-on-mac-os-x debugger it says EXC_BAD_ACCESS. int main () { int j,k,l; int twelve[13][13]; void mat(int twelve[13][13]); printf("input original tone row \n"); for(j=0;j<=11;j++) { scanf("%2i",&twelve[j][0]); } mat(twelve); for(k=0;k<=11;k++) { for(l=0;l<=11;l++) { printf("%i ",twelve[l][k]); } printf("\n"); } return 0; } void mat(twelve) int twelve[13][13]; { int j,k,l; int temp; /*inversion*/ for(j=1;j<=11;j++) { twelve[0][j] = 12 - twelve[j][0]; } /*fill in columns*/ /*this sections seems to be what's crashing it */ for(k=1;k<=11;k++) { for(l=1;1<=11;l++) { temp = twelve[0][k] + twelve[l][0]; if(temp >= 12) { twelve[k][l] = temp - http://stackoverflow.com/questions/2061445/bus-error-in-simple-mac-osx-c-program 12; } else { twelve[k][l] = temp; } } } } c xcode osx exc-bad-access share|improve this question edited Oct 10 '12 at 16:48 athspk 4,99872549 asked Jan 14 '10 at 0:42 Levi 613 Compile with -g or use XCode's debugger, and let us know what line of code has the crash ;v) . –Potatoswatter Jan 14 '10 at 0:46 1 this code gives me the willies. –Stephen Canon Jan 14 '10 at 0:46 Wow, I haven't seen K&R C in ages... –R Samuel Klatchko Jan 14 '10 at 1:13 add a comment| 2 Answers 2 active oldest votes up vote 11 down vote There is a typo in the inner loop condition of the mat() subroutine. This is why I don't like 'l' (el) as an index. for(l=1;1<=11;l++) you meant "l < 11" (el) not "1 < 11" (one) One is always less than eleven, so the l (el) index increases without bound, which leads to an illegal memory access when index gets too large. share|improve this answer edited Jan 14 '10 at 0:53 answered Jan 14 '10 at 0:45 Christopher Bruns 4,74912848 1 +1. i, j, k is probably a better option for loop indices. –Anon. Jan 14 '10 at 0:48 add a comment| up vote 3 down vote About 10 lines up from the bottom of your code you have the statement: {for(l=1;1<=11;l++) should that be {for(l=1;l<=11;l++) share|improve this answer edited Oct 10 '12 at 16:38 meagar♦ 136k21203238 answ
von GoogleAnmeldenAusgeblendete FelderNach Gruppen oder Nachrichten suchen
10 iPad Air 2 iPad mini 4 (2015) iPad Pro iPhone 6s iPhone 7 iPhone 8 (2017) iPhone SE iPod nano iPod shuffle iPod touch Mac mini Mac Pro MacBook Air MacBook Pro macOS Sierra Retina MacBook Thunderbolt Display tvOS 10 watchOS 3 Buyer's Guide Forums Forums Front Page Roundups Buyer's Guide Forums Roundups OS X Yosemite MacBook Air iOS 8 Apple Watch Log in Sign up Recent Posts Spy Support Support Quick Links General FAQ MacRumors Theme FAQ Contact Us Lost Password Menu Search titles only Posted by Member: Separate names with a comma. Newer Than: Search this thread only Search this forum only Display results as threads More... Useful Searches Recent Posts Options Please select a forum to jump to News and Article Discussion MacRumors.com News Discussion Mac Blog Discussion iOS Blog Discussion iPhone, iPad, and iPod Touch iOS iOS 9 (Beta) iOS 8 iOS 7 Older iOS Versions iOS 6 iOS 5 and earlier iPhone iPhone iPhone Tips, Help and Troubleshooting iPhone Accessories iPhone Launch Meetups iPad iPad iPad Tips, Help and Troubleshooting iPad Accessories iOS Apps iPod touch iOS Programming iPod Jailbreaks and iOS Hacks Alternatives to iOS and iOS Devices Apple Watch Apple Watch Apple Watch Accessories Apple Watch Apps Macs OS X OS X OS X El Capitan (10.11, Beta) OS X Yosemite (10.10) OS X Mavericks (10.9) Older OS X Versions OS X Mountain Lion (10.8) Mac OS X Lion (10.7) Desktops iMac Mac Pro Mac mini Notebooks MacBook MacBook Pro MacBook Air Mac Basics and Help Mac Programming Buying Tips and Advice PowerPC Macs Mac Accessories Windows, Linux & Others on the Mac Mac Apps and Mac App Store Mac OS X Server, Xserve, and Networking Apple TV Apple TV and Home Theater Apple TV Apps tvOS Programming Apple and Apple Services Apple, Inc and Tech Industry Apple Music, Apple Pay, iCloud, Apple Services Special Interests Design and Graphics Digital Audio Digital Photography Digital Video Apple Collectors Web Design