![]() |
C Programming in Linux - Printable Version +- Linux Lite Forums (https://www.freecinema2022.gq/forums) +-- Forum: Development (https://www.freecinema2022.gq/forums/forumdisplay.php?fid=7) +--- Forum: Coding (https://www.freecinema2022.gq/forums/forumdisplay.php?fid=33) +--- Thread: C Programming in Linux (/showthread.php?tid=1738) |
C Programming in Linux - hhbuur - 04-14-2015 hi i am trying to learn to program in c. and is using this guide. C Programming in Linux © David Haskins 2008 now at chapter2_1.c i got in to a problem the compelling will not run and I can not see what's wrong, is there som help to get? Code: #include <stdio.h> Code: Programming_In_Linux$ gcc -o data1 chapter2_1.c -lc Re: C Programming in Linux - gold_finger - 04-18-2015 Bumping this for the OP. Anyone here code in C that can help? @hhbuur, I have next to no experience, but I think I see one error. Correct this first, run program again and see if you still get other errors. I could be wrong, but I believe that "DEFINE" should be "define" in this line: Code: #define STRINGSIZE 256 P.s. Does the book you're working from have a free version on the Internet? If yes, can you provide a link to the problem you're working on. Re: C Programming in Linux - hhbuur - 04-18-2015 yes that made a difference, now it is compelling and the output is correct but there i still a problem. Code: chapter2_1.c: In function ‘main’: and to your question, i get my book from bookboom Code: http://bookboon.com/ Re: C Programming in Linux - gold_finger - 04-18-2015 I ran a test of your code in VirtualBox install of LL and I did not get the errors you are reporting. I called the program "sample.c" and saved it to the Desktop. Here is the exact code I used: Code: #include <stdio.h> I compiled it with this code: Code: homey@homey-VirtualBox:~/Desktop$ gcc sample.c -o sample Ran it with this command and got the following output: Code: homey@homey-VirtualBox:~/Desktop$ ./sample Compiled it again with the following command to match what you did, ran program again and got the same output as above: Code: homey@homey-VirtualBox:~/Desktop$ gcc -o sample sample.c -lc P.s. Is this line of output what you were expecting it to be? Code: char=1 byte int=4 bytes float=4 bytes Re: C Programming in Linux - hhbuur - 04-19-2015 i get the same outputs as before no mater witch of yours variations I try, can there may be a differences in the versions of gcc, makes the difference in the output, the version i haw install is 4:4.8.2-1ubuntu6 , and your ? I get the same result as in the book Re: C Programming in Linux - gold_finger - 04-19-2015 (04-19-2015, 12:05 PM)hhbuur link Wrote: i get the same outputs as before no mater witch of yours variations I try, can there may be a differences in the versions of gcc, makes the difference in the output, the version i haw install is 4:4.8.2-1ubuntu6 , and your ? I get the same result as in the book I used 32-bit LL 2.2 and the gcc package is the same version# as yours. I just downloaded the book so I could see exactly what the exercise was. Aside from making the correction from "DEFINE" to "define", it all looks the same as what I input and the output from mine matches that of the book (with no error messages). In all likelihood, if you're still getting error messages, you have a typo somewhere or a missed character. Double-check what you have. From what you've posted, the only other thing I noticed is that you had a space between "sizeof" and "(int)" on this line: Code: printf("memory used:%d bytes\n", However, I purposely ran the code with that space also and it did not give me an error -- so I doubt that is the source of your problem. Only other thing that I can think of is that you made the change from "DEFINE" to "define", saved the document, but did not re-compile the program with the new change. You need to save the change in the text file, then re-compile it before running the program again. Aside from that, I'm clueless as to why it's not working for you. Re: C Programming in Linux - avj - 04-19-2015 It appears that you missed the } on the very last line. Re: C Programming in Linux - hhbuur - 04-21-2015 i haw the } on the last line. I will continue with exercises and see how it's going to proceed ![]() |