ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hello everyone,
I have written a code to calculate some values based on i/p given.I have compiled and run the program in windows turbo C , but when i run it in linux , it gives segmentation error.Help me in rectifying this.
Varadharajan.
Originally posted by Varadharajan hello everyone,
I have written a code to calculate some values based on i/p given.I have compiled and run the program in windows turbo C , but when i run it in linux , it gives segmentation error.Help me in rectifying this.
Varadharajan.
Originally posted by Varadharajan hello everyone,
I have written a code to calculate some values based on i/p given.I have compiled and run the program in windows turbo C , but when i run it in linux , it gives segmentation error.Help me in rectifying this.
Varadharajan.
Hard to do on so few an information - you should at least have posted your code. However, in my own experience, problems of the sort (works on one os, segfaults on another) usually are caused by undefined variables or pointers, something like
char *szmystring;
szmystring[0]=0;
/*szmystring is undefined here, but there are typical values which undefined pointers tend to contain and which are os/compiler dependant; for example, under ms toy os it's very likely some 0xcdcdcdcd or 0xcececece (don't recall which). Hence it may segfault under one, while seeming to work on another*/
Windows folks like to do this sort of thing sometimes:
Code:
char *foo = "hello world\n";
...
// capitalize the H in hello
foo[0] = 'H';
// or sometimes this:
// append something to hello world
char *blah;
blah = strcat(foo, "woo!\n");
Both of these are wrong because they modify the string that foo points to, which is a constant string. These examples tend to work on windows, but they won't with gcc on linux (maybe not with gcc on windows either?)
If you don't believe me on the second one, read the man page for strcat it's non-obvious that it modifies its first argument.
but anyway, the question was really vague so we're all just pontificating
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.