Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm new to programming. What I want is to know as much about programming as I possibly can, and start off with what people say is a good start: programming with C.

I have this PDF called "Teach Yourself C In 21 Days" and it looks to be a rather simple introduction to the language. I swapped Windows 7 for Ubuntu yesterday, after having trouble installing it for over 12 hours (post I made regarding the issue). The main reason why I came to Ubuntu is to dive into an OS made for people wanting to learn how to develop software or even a new OS, like Steam's new OS based off Linux. The problem I'm facing, though, is that there seems to be some functions that don't translate with Ubuntu's Terminal (I followed instructions similar to this post to get started).

What I'm asking is whether or not there is some way I can look up corresponding functions used in C programming for gcc? Or is there a PDF or website that teaches C/C++ through gcc?

I will also accept recommendations for where/how/what I SHOULD start learning.

More info


I figure my question can be better answered if I include the actual problem I have. The PDF has this exercise:

  1. What does the following program do? (Enter, compile, and run it.)

1:-- /* EX2-5.C */

2:-- #include

3:-- #include

4:-- main()

5:-- {

6:-- char buffer[256];

7:--

8:-- printf( "Enter your name and press :\n");

9:-- gets( buffer );

10:--

11:-- printf( "\nYour name has %d characters and spaces!",

12:-- strlen( buffer ));

13:--

14:-- return 0;

15:-- }

I found out that in order to do some simpler code from earlier exercises, I needed to add 'int' in front of 'main' for it to work. So imagine that being added to the code. The error I get when I try to check for the errors is as follows:

EX2-5.c: In function ‘main’:

EX2-5.c:9:2: error: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Werror=deprecated-declarations]

gets(buffer);

^

EX2-5.c:12:4: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ [-Werror=format=]

strlen(buffer));

^

cc1: all warnings being treated as errors

share|improve this question
1  
Unfortunately this isn't really on-topic here, mostly because you're just asking for resources. However, you should really check learncpp.com out. It teaches through IDEs and gcc. –  Seth Jan 27 at 18:44
    
I'll give it a try. Thank you. –  ajborkowski Jan 27 at 18:52
add comment

closed as off-topic by Seth, dobey, guntbert, karel, Eric Carvalho Jan 29 at 2:22

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – Seth, guntbert, karel, Eric Carvalho
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

There is a nice package to display C function header, named ref. To know more about it see man ref. It has a good database where you can find the list of C library functions with brief introduction.

To use it first install ref using the command below,

sudo apt-get install elvis-tools

The functions are listed in the file /usr/share/elvis/stubs/ansistub.c. You can directly look into it to know about the functions as,

$ less /usr/share/elvis/stubs/ansistub.c 

or to know about a function

$ ref printf
"printf", /usr/share/elvis/stubs/ansistub.c, line 553:
/* <stdio.h> Print a formatted string to stdout */
int printf(const char *format, ...)
share|improve this answer
    
I have it already shown, look into the ansistub.c file to get a list of c functions. If you use the command less /usr/share/elvis/stubs/ansistub.c in terminal you will be able to see the list. –  souravc Jan 27 at 19:24
    
or if you just enter the command ref < c_function_name > you will get the function prototype and name of the header file that contains it. –  souravc Jan 27 at 19:26
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.