Simple C code compiles on Leopard and Tiger, doesn't run on Leopard

Hello all,
I have a simple program I wrote that reads in information from a file, does some stuff to it, and then writes a new file. The program compiles correctly on Leopard, Tiger, and Fedora, but only runs correctly on Tiger and Fedora. The output file of the Leopard run program has a line of gibberish followed by missing information. I've compiled it on Leopard using both gcc versions 4.0.1 (the Leopard standard) and 4.2.2, and still get the same bad output file. Any thoughts?
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main () {
int n=0;
float p[5261][3];
char *line;
line=malloc(sizeof(char)*100);
FILE *inputfile;
inputfile=fopen("initial.crd","r");
FILE *outputfile;
outputfile=fopen("new.initial.crd","w");
char a[4], b[4], c[4];
int atomid,molid;
float phi, theta, d;
float r=2;
line=fgets(line,100,inputfile);
fprintf(outputfile,"%s",line);
line=fgets(line,100,inputfile);
fprintf(outputfile,"%s",line);
line=fgets(line,100,inputfile);
fprintf(outputfile,"%s",line);
line=fgets(line,100,inputfile);
fprintf(outputfile,"%s",line);
while(n<5260){
line=fgets(line,100,inputfile);
/printf("%s",line);/
sscanf(line,"%d%d%s%s%f%f%f%s",&atomid,&molid,&a,&b,&p[n][0],&p[n][1],&p[n][2], &c);
/*printf("%d %d %s %s %f %f %f %s\n",atomid,molid,a,b,p[n][0],p[n][1],p[n][2],c);*/
d=sqrt(powf(p[n][0],2)powf(p[n][1],2)powf(p[n][2],2));
d+=r;
theta=atan(p[n][1]/p[n][0]);
phi=atan2(p[n][1],p[n][2]);
fprintf(outputfile,"%5d%5d %-4s %-4s%10.5f%10.5f%10.5f %s\n",atomid,molid,a,b,dsin(phi)*cos(theta),d*sin(phi)*sin(theta),dcos(phi),c);
n++;
line=fgets(line,100,inputfile);
fprintf(outputfile,"%s",line);
line=fgets(line,100,inputfile);
fprintf(outputfile,"%s",line);
line=fgets(line,100,inputfile);
fprintf(outputfile,"%s",line);
fclose(inputfile);
fclose(outputfile);
return 0;
}

robkal wrote:
Also, the code shown, as is, runs perfectly on Tiger and various versions of Fedora. The output file from these OS's is perfect. Do you know of a reason that Leopard would be different?
<sigh> Somehow I knew you were going to say that.
The reason Leopard is different is because it is acting correctly whereas the other are not. Linux doesn't surprise me, but I would have expected more about of Tiger. That's unfortunate.
I just tried your code on my Linux box (I'm not at my Mac now) and it seg faults. I changed the sizes of a, b, and c to 5 and it runs properly. It has nothing to do with Leopard or 64 vs 32 bit. In C, if you store a string with 4 characters, you had better make room for 5.

Similar Messages

  • Installing Leopard and Tiger on the same computer ...

    Hi,
    How could I install both system, Leopard and Tiger, on my iMac G5 giving me the possibility to startup from one of them at a time ...
    I want this to have this possibility to run occasionally classic (with Tiger) while using mainly Leopard. Is this possible ? What are the drawbacks of this possibility ?
    Thanks in advance.

    Thanks for your feedback ...
    Smokerz's comment was not clear to me. I thought he meant that having 2 «Applications» folders is «complicating» things. I am french canadian and sometimes english way of speaking is not fully understood. That is why I asked for a confirmation.
    I thought that since all partitions would be available, that with 1 «Applications» folder, apps could be used in both world. If I have 2 versions of MS Word, witch one will open when double clicking on a Word document. I think that what we have to keep in mind is that apps have to be Tiger «and» Leopard compatible. Maybe I misunderstand, but that is what I see as the potential problem.
    If what Smokerz meant is to have 2 independent systems, it is not what I was looking for when beginning this thread. I have been using OS 9 and OS x with the advantage of switching from one environment to the other and loved that possibility. I thought that I could have an environment where all my documents could be available when working either in Tiger or Leopard. If I desired to have OS 9 for my accounting package, I would startup my Imac with Tiger and Classic. Once finished, I would reboot with Leopard.
    I know that there is an emulator called «SheepSaver» to run OS 9 on Intel machine, but have not been to confirm the speed of that solution. Maybe it is also possible to run it on PPC machines ... I will look into this possibility.
    Thanks for helping.

  • MacPro with both Leopard and Tiger drives. Want to switch iTunes How

    I am running a MacPro with both Leopard and Tiger drives. I finally want to switch everything to Leopard and its drive. I have iTunes on the leopard drive but have never used it. How can I transfer my iTunes music, iPhone Apps etc. from the Tiger iTunes to the Leopard with the least amount of fuss?

    Hello hassiman,
    For additional information regarding moving the entire library from the 10.4 partition to the 10.5 partition, see this article:
    http://support.apple.com/kb/HT1449
    If your iTunes Library is substantial, you may want to consider backing it up to an external location as well:
    http://support.apple.com/kb/HT1751
    Hope this helps,
    Charles H.

  • Problems building w/ Snow Leopard and iPhone SDK 3.0 Snow Leopard

    Suddenly having problems building and codesigning after upgrading to Snow Leopard and iPhone SDK 3.0 Snow Leopard.
    Profile set to Distribution, Device 2.2.1 Distribution, as has worked in the past.
    The build fails with this error:
    Command <com.apple.tools.product-pkg-utility> failed with exit code -1
    The below section is highlighted in Build Results.
    ProcessingProductPackaging /Users/harvey/Documents/iPhoneApp_Work/Listening-Hiragana/iPhone_Comprehension_timerharvey/entitlements.plist "/Users/harvey/Documents/iPhoneApp_Work/Listening-Hiragana/iPhone_Comprehension_timer_harvey/build/iPhoneComprehension.build/Distribution-iphoneos/Kana Listening.build/iPhone_Comprehension.xcent"
    cd /Users/harvey/Documents/iPhoneApp_Work/Listening-Hiragana/iPhone_Comprehension_timerharvey
    setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/u sr/bin:/bin:/usr/sbin:/sbin"
    <com.apple.tools.product-pkg-utility> /Users/harvey/Documents/iPhoneApp_Work/Listening-Hiragana/iPhone_Comprehension_timerharvey/entitlements.plist -entitlements -format xml -o "/Users/harvey/Documents/iPhoneApp_Work/Listening-Hiragana/iPhone_Comprehension_timer_harvey/build/iPhoneComprehension.build/Distribution-iphoneos/Kana Listening.build/iPhone_Comprehension.xcent"
    Any ideas? This is really strange.
    The same error occurs when trying to build for Device - 3.0, and any other version it seems.
    This is especially frustrating as I'm simply trying to update an app that I released before I upgraded.
    I will love whoever helps me forever and ever.
    saikyo

    Found the new SDK on the CD. Now I am running XCode 3.2.
    I'm talking to myself now for the benefit of future readers.
    On the Dev Center I see the note:
    "Important: You will need to re-install the iPhone SDK for Snow Leopard if you plan on developing iPhone applications after upgrading your Mac to Snow Leopard and installing Xcode 3.2."
    So I'm going to download and install the iPhone SDK 3.0 (Snow Leopard) from the SDK downloads area on the Dev Center page. This seems weird to me as it's 3.0... but I'm running 3.2 now... I guess this will just update my 3.2?
    I also notice that when I run XCode 3.2 I don't have Simulator as an option anymore in my profiles.
    Going to go ahead with the update now and see how it goes.

  • Setting the Software Update Server on Snow Leopard, Leopard and Tiger

    I have made an app that will set the Software Update Server on Snow Leopard, Leopard or Tiger. It will set the Software Update Server by checking the Server's version to see if it is compatible with your OS version. If you try to use a Leopard (no Snow Leopard Hack (See http://discussions.apple.com/message.jspa?messageID=10297359#10297359)) or Tiger Server with Snow Leopard it will say it is not compatible. If it is it will set it. If you are trying to use a Tiger Server with Leopard it will set it but you will only get Tiger updates.
    The app is beta, if you find any problems or have any comments please reply.
    Download: http://iwczone.co.uk/projects/iSetSU/

    You might want to look into throwing Software Update Enabler onto your clients.
    http://www.macupdate.com/info.php/id/18059
    Basically, it's just a little app that points the client in the direction of the Software Update Server - you just enter the IP of the server into the config field. With a standalone server I don't think you can get the clients to see the server without something showing them the way.
    It's really very tiny and simple - I believe it just edits a com.apple.softwareupdate.plist or some such, but it made life a lot easier for us in our environment.
    Hope that helps.

  • ICal bug subscribing/publishing between Leopard and Tiger?

    It seems there is a strange incompatibility between iCal 2.0.5 (Tiger) and iCal 3.0 (Leopard).
    I work for a company where 10 employees share their calendars through a private server.
    Everyone publishes his/her calendar and is subscribed to all the other calendars within the company. So effectively, everyone sees his own calendar in iCal as read/write and all the other calendars as read- only.
    Last week 3 machines were upgraded to Leopard and since then trouble started.
    Now, when someone on a Leopard machine creates an event and invites someone who is on a Tiger machine, the Tiger machine can accept the invitation but as soon as it is accepted the event disappears from the Tiger calendar.
    As soon as the subscription to the Leopard calendar is removed, the event reappears on the Tiger calendar.
    The results are the same when a Tiger user invites a Leopard user on the Tiger machine.
    I tried this both with a private server and dotMac.
    Does anyone have the same experience and perhaps a solution to it?
    Right now the only solution I see is to upgrade all the machines to Leopard.

    Although I don't have a solution, I share your pain. I had less problems with iCal even before upgrading to Leopard.
    What I can find across forums discussing bugs in iCal for Leopard is that, for the moment, there are a lot of small annoyances regarding alarms, compatibilities and inability to edit items without causing it to crash, amongst other topics.
    The frustration level is growing as no sign of help seems to be come from Cupertino until now, the best help is on the forums, by power users themselves.
    Message was edited by: batequeixo

  • VBR different under Leopard and Tiger

    I re-encoded my iTunes library using the import settings for 256kbps VBR. This was all done a few weeks back and all of the tracks show as having a bitrate of 256. Now I upgraded to Leopard and imported 4 more CDs and they all show values on the tracks from 263-287kbps. The strange thing is, iTunes is the same version 7.4.2 under Tiger and Leopard. Did my library not encode in VBR or was iTunes under Tiger just showing the bitrate setting? My ears can't tell the difference anyway, but it does seem odd.

    I had to do a erase and install with leopard and it required a reinstall of ilife.
    I went into Preferences to change items and in advance the AIFF encoder no longer gives you the option to get a higher rate: ex: 128 to 320 .
    It now says All Automatic !!
    have you noticed that ??
    What is automatic and why can we no longer control the import rate ???
    Any ideas ??
    Unless I am missing something.
    greg

  • Leopard and tiger

    Hello,
    I've just upgraded to Leopard and it is working great (I love the new features and my apps work faster it seems). However, our jobs database program at work is incompatible with it. Since I do a lot of remote admin work from home, this is a significant issue. Is there a way I can install Tiger (and use it as a 2nd OS option on my Quad) alongside Leopard without wiping out my drive? What would be the best method to go about this.
    Thanks much for your knowledge.

    No bootable backup of your previous Tiger installation? Bad juju, that. Now, the only way to revert is to install Tiger onto another disk/volume, reinstall all the Applications, and reset all your preferences. Step one before updating/upgrading is make a bootable backup/clone and test it. See
    http://docs.info.apple.com/article.html?artnum=106941
    http://www.macmaps.com/upgradefaq.html
    http://www.macmaps.com/backup.html
    http://www.thexlab.com/faqs/installswupdates.html
    http://www.thexlab.com/faqs/backuprecovery.html

  • Can I have Leopard and Tiger on different drives???

    The whole question: Can I have Tiger on one drive, Leopard on the other, and run the same programs from whichever one is the boot drive?
    Will having the other OS on a nearby drive get in the way of anything? Both internal drives have Tiger on them, so If one goes nuts, the other might be helpful, but can that second drive become Leopard, so I can boot it and poke about? Will the Leopard drive be able to run the programs that are currently working within Tiger?
    Is this asking too much?

    I'm not sure I understand you question
    Yes you can run Leopard on one drive and TIger on another - I currently have leopard on an external drive and Tiger on my internal drive
    At David DeCristof's suggestion I cloned TIger onto the external drive (using Carbon Copy Cloner -- CCC) and upgraded to Leopard there
    Since both drives contain all the same data and applications (at least started that way) I can run anything on either -- if I save data from Tiger that I want to keep after I clone Leopard back to my internal drive I will have to be careful to stove it on the external drive
    It is, IMHO, a smart way to upgrade
    Larry Nebel

  • Many programs I used to use in Tiger doesn't work in Leopard

    Here are the ones I've noticed have not been working or have errors:
    iMovie
    iChat
    Yahoo Messenger
    Adium
    VisualHub
    There are probably like 10 more but I haven't seen it yet. Why are so many programs are acting like this. I was thinking it was becasuse it wasn't ugpraded enough but I did install the newer version and it doesn't work.

    Well, haven't we had to deal with a slew of updates every two years?
    And at least Vista x64 is probably more secure, supports EFI (UEFI 2.).
    The same people that would need a Mac Pro (dual cpu, 8GB RAM, etc) would be looking at 64-bit.
    Did not Apple tout the G5 from IBM as finally being a 64-bit system? But yes, even Adobe CS3 is still 32-bit and limited to 3.5GB of user space, which there are work arounds for.
    One person I tried to help was using Maya but his version doesn't work with Leopard, and blames Apple and 10.5 it seems, rather than realize he needs to consider an 8-core system rather than 4-core, more memory, make better use of disk and RAID, and of course... upgrade software or... WAIT FOR MAYA AND 10.5.x to catch up to each other!
    People assume you have to wait for SP1 for Windows, but think they should jump rigtht in, when we all have seen that X.3 is usually the first "sweet spot" in any release.

  • Have downloaded firefox update 3 times and it doesn't run

    I have just started to use firefox on my pc which has windows 7. I keep getting a message saying I need to update the version of firefox, so I down load it and it says it is downloaded ( I now have it 3 times) but it doesn't run and still keepstellin me I need to upgrade it??? DO I just go back to internet explorer???

    Your browser reported to the forum that you are running version 3.6.6. Can you verify that using the Help > About Firefox dialog?
    Which file did you download: Firefox 3.6.27 or Firefox 10.0.2?
    (If you need to re-download, you can choose from the files on these pages:<br>http://www.mozilla.org/en-US/firefox/all for 10.0.2 or <br>http://www.mozilla.org/en-US/firefox/all-older for 3.6.27)
    Make sure to close Firefox before launching the installer for the newer version. Do you get any error messages when you start it? It might take a minute for the installer to check itself before you get a dialog.

  • I bought an app, and it doesn't run

    I downloaded a pay app, " Gastos Celular " , and it doesn't work. When I try to open it, it just shows the app for a second and then, the app shutdown. I restarted my iphone 5, and try to reinstall the app, but nothing change. I wonder if apple can give my money back or at least solve the problem.

    Hi Tincho67,
    Thanks for visiting Apple Support Communities.
    If an application you purchased is not behaving, even after troubleshooting, you can report the issue with your purchase:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBookstore purchase
    http://support.apple.com/kb/HT1933
    You may also find this article helpful for further troubleshooting:
    iOS: Troubleshooting applications purchased from the App Store
    http://support.apple.com/kb/ts1702
    Regards,
    Jeremy

  • Leopard and Tiger on Separate Drives: questions. Many externals. Graphics

    Hi,
    I have multiple Macs, most networked, and have installed Leopard on all but my "graphics" computer. I use this one for my photography, and am just gathering my nerve to move. I am wondering whether to wait, to install Leopard on a separate internal drive, or to upgrade.
    My system: Mac Pro Quad (16 Gigs max, and I have 16 gigs). 4 internal 750Gig drives. Sonnet Tech. PCI-e port multiplier SATA card (4 external plugs: 2 connected to 5 drive bays). Epson 4800 printer using ColorByte Software ImagePrint 7. Other key apps, CS3, Lightroom, Aperture. Misc. usb and firewire drives and devices including WACOM. My photo libraries, are all on the external SATA drives, and backed up to other external SATA drives. I use Chronosync for the backup. We are talking almost a Terrabyte, so I wasn't planning to use Time Machine.
    Advice? Should I install leopard on a separate internal drive, but leave Tiger? Can I use data files from other drives with either operating system without screwing up my files. Can I use application files located on the Tiger boot drive, from Leopard?
    So, alternate boot drives?
    Is anyone aware of Leopard issues with any aspect of my system, as described?
    If I go with leopard, do I start from scratch and reinstall everything (which is a total pain considering the number of serial numbers, and upgrades, involved?
    Anything I should have asked but didn't? Thanks for the help

    Keep Tiger. Install Leopard on a separate volume, using the Erase & Install option, followed by migrating from the Tiger volume, because there have been problems, especially with ownership and permissions. See these for details:
    http://discussions.apple.com/thread.jspa?messageID=5757385
    http://discussions.apple.com/thread.jspa?messageID=5666369
    http://discussions.apple.com/thread.jspa?messageID=5646414
    That allows immediate recovery into a known, good state.

  • Running Leopard and Tiger at the same time VMWare fusion/Parallels?

    Hello,
    I was wondering, is it possible to run Tiger and Leopard at the same time? Some older applications won't run properly in Leopard. The iMac came both with Tiger and Leopard (last November). It has been described elsewhere that one can install Tiger and Leopard on separate partitions and switch by rebooting. But it would be nice if one could run Tiger in Leopard like one can run Windows/Unix using VMWare Fusion or Parallels. Is that feasible?
    best wishes

    I agree with you that virtualizing Mac OS X would be great. I'm an Apple technician and it would really help with my work. But Apple's EULA does not permit the use of OS X in a VM. They changed OS X Server's EULA recently to permit it, but not the "client version".
    So your Mac can virtualize nearly any OS out there, but not OS X. And I believe (not sure) that a VM of OS X Server will only run on OS X Server.

  • Go To Chat failure in mixed environment - Leopard and Tiger iChat

    Hi there.
    I've been using iChat on an OS X Tiger machine and using the "Go to chat" feature to communicate with several other people at work. It recently started failing when they all upgraded to Leopard. I am not sure if this is a Leopard issue or what, but since that seemed to be the only common change, it seems a good place to start.
    The error I receive when trying to go to chat is:
    AIM error:
    Couldn’t request chatroom “MyChatRoom”. (An AIM service error occurred. The server message was: Serv:RequestTimeout)
    The chatroom name has been changed to protect the innocent.
    I've tried changing my port to 443 as some have suggested.
    We're all on high speed connections.
    Another data point is that around the time they all started upgrading to Leopard, some of us would drop out of the chatroom or become unable to send to chat - even after relogging, restarting, etc.
    We can chat with each other one-on-one just fine. It's just the chatroom which seems to be...somewhat broken.
    Thanks in advance for any tips here.
    -T.

    From what you post about trying different things I would delete com.apple.ichat.AIM.plist and restart iChat
    2:50 PM Sunday; November 18, 2007

Maybe you are looking for