LinuxAnswers DiscussionThis forum is to discuss articles posted to LinuxAnswers.
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.
Looks nice. Hopefully java expierence will be helpful, I want to learn C and my school never has enough people sign up for the class to have it. Thanks
Looks good but my problem is that SuSE Office desktop does not come with a C compiler. What would be really useful for me is a section on how to get started if you don't have a C compiler.
under several flavors of unix make does not require tab characters in rules. They don't break anything if they are there.
The other thing which confuses new folks : K&R, ANSI "styles"
Code:
/* ----- version 1 */
int main(argc, argv)
int argc;
char **argv;
{
return 0;
}
/* ---- version 2 */
int main(int argc, char *argv[])
{
return 0;
}
/* --------- version 3 */
int main(int argc, char *argv[]){
return 0;
}
Believe it or not, C shops usually prefer style #3 - very 'ANSI'
Style 2 is "okay", style 1 is a no-no.
A lot of examples I've seen that come with downloads were written in 1985 and look like version 1.
While it doesn't REALLY matter, this is confusing as hell to newbies.
You might want to consider adding a section talking about style.
Plus, version 1 won't compile under cc -Aa on HPUX v11.0 for example. So, it can cause some issues down the road.
Although you begin the article saying it is inended for folks who know C but do not know how to build a program under Linux, you spend much of the article expplaining the simple C program. You spend very little of the article saying how building it is different in Linux. I have some 15= year old experience In C under DOS, Windows and Unix (a little). I was hoping to see this article show how to set up my environment under Linux and how some of the tools differ or have improved.
When I saw the first line in the 1st program as "#include" with no argument as to WHAT to include and your statement that it meant you were using the stdio library, I thought I was on the right track. However, gcc gives the expected errors on that line (yes, I named the file differently):
inctest.c:1:9: error: #include expects "FILENAME" or <FILENAME>
inctest.c: In function ‘main’:
inctest.c:5: warning: incompatible implicit declaration of built-in function ‘printf’
I infer not that your article is wrong, but that your environment is set up differently. Specifically, I found some other articles referring to default includes but they did not help either. Now I don't mind; in fact, I like being explicit about my includes so this is not a big deal detail. What I would like to find though is some information that really IS about how building C programs in Linux is different from other environments. Any suggestions?
When I saw the first line in the 1st program as "#include" with no argument as to WHAT to include and your statement that it meant you were using the stdio library, I thought I was on the right track. However, gcc gives the expected errors on that line (yes, I named the file differently):
inctest.c:1:9: error: #include expects "FILENAME" or <FILENAME>
inctest.c: In function ‘main’:
inctest.c:5: warning: incompatible implicit declaration of built-in function ‘printf’
Sadly, the author must have forgotten that his text would be displayed "as-is" in a browser and that they don't render < or > very well. In order to display the greater-than or less-than signs, you must use the following... (hopefully the author will fix it)
I understand the author's kind intentions, but this is a very poor article. I'm not sure how the LQ mods allowed it to be posted, and furthermore, i'm not sure why or how the author didn't preview his work, or check/fix any mistakes afterwards. I'm not referring to tricky or blind-eye mistakes, but big ones such as the #include bit on the top.
Furthermore, adding to the comments said above, this hasn't really shown us any differences between building a typical C program, and building a C program for Linux.
And as an added suggestion, some outside links to more indepth tutorials for certain sections would do good.
I hope this article gets fixed. It is valuable and it's needed in LQ.
i got 2 questions and i try to write codes for this. its dosent working propoerly. anyone know how to do coding for this questions. thanks
1) Instead of producing the summation of the given non-negative integer,
modify this program and make it create only one
thread that will calculate the factorial. When the thread finishes execution,
the parent thread will output the factorial calculated by the child thread
2 ) Besides of producing the summation of the given non-negative integer,
modify this program and make it create two threads.
One thread is to produce the summation of the given non-negative integer;
the other thread is to calculate the factorial. When the two child threads
finish execution, the parent thread will output the summation and the
factorial of the given non-negative integer
char c[20];
printf("\n\nPlease enter the name of the file: ");
scanf("%s",c);
printf("\nthe name you type is : %s\n",c);
system("mkdir c"); problem now in line 5 ,it make the folder name as c not the string i have enter
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.