Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - matias

Pages: [1]
1
C - C++ / Re: Interface Programming using C's gtk libraries
« on: February 24, 2016, 02:27:15 pm »
Contributing to the development is not my goal, no. I just see how easy things seem to be done in other languages, and how learning those things in C often gives you a wider understanding of the entire topic in question.

Take structures for example. In my case, it took me a few weeks to finally understand all their applications and how to use them (and I'm still struggling sometimes); pointers to structures, array of structures, functions returning pointers to structures, etc.

In Java, they call them Classes and Objects, tell you a little about the notation, and that's it, at least so far... And I'm not saying Java is a bad programming languaje, not at all. I'm saying: "If it is that easy in Java, sure there must be some badass code in C behind it"

My end goal is to learn it.

2
C - C++ / Re: Interface Programming using C's gtk libraries
« on: February 20, 2016, 01:34:34 am »
Sorry! Corrected it. Now I got this:

Code: [Select]
gcc: error: pkg-config --cflags --libs gtk+-2.0: No existe el archivo o el directorio

`~`

3
C - C++ / Re: Interface Programming using C's gtk libraries
« on: February 20, 2016, 01:15:53 am »
Okey, So I got a program called 'int.c' and I typed the next thing:
gcc int.c pkg-config --cflags --libs gtk+-2.0

And got the next errors:
Code: [Select]
gcc: error: pkg-config: No existe el archivo o el directorio (=file or directory does not exist)
gcc: error: gtk+-2.0: No existe el archivo o el directorio ( " )
gcc: error: unrecognized command line option ‘--cflags’
gcc: error: unrecognized command line option ‘--libs’

4
C - C++ / Interface Programming using C's gtk libraries
« on: February 19, 2016, 06:59:07 pm »
Lately I've been watching some lectures about Java online. It amazed me how in my second day of learning I reached the topic of Objects, creating windows, using labels, and so on. Next thing I did was searching on Google how to write such codes and programming user interfaces in C.

It appears to be that GTK C libraries handle this part of C programming, but that's all I could find about the topic until now. I visited the website http://www.gtk.org/ and tried to install the latest version , but after a couple of hours and tons of errors (I use Ubuntu 15.10) I gave up. On the other hand, it seems that I already have an older version of gtk installed, so installing the latest version isn't completely necessary.

Problem is, I tried to do an example, and included the <gtk/gtk.h> library, but the compiler doesn't recognize it...

Anyone with a little experience at this?

5
C - C++ / Re: Rearranging Numbers in Ascending Order
« on: February 17, 2016, 01:41:08 am »
Hi there.

Well, as far as I can see, there are a lot of basic concepts you would have to learn before trying to write a program like that. What I know is from the C languaje, but it is also useful for this case.

First: The 'i' index initialization in the 'for' loop ---> You initilalized 'i = 1', therefore ignoring the first element of 's', which is s[0].

Second: temp value assignation and k vector---> you defined an array of integers called 'k', but you never gave any value to it's elements. You should know that the C preprocessor evaluates statemets in a certain order, according to their "weight" in C syntax. In this case, when you write 'temp = k', the preprocessor evaluates the statement from right to left. In other words, it takes the value of 'k' and assignes it to the variable 'temp'. As you never assigned any value to k before that, you're basically giving junk code to temp.

Third: Printing results ---> The "printf( "%d\n", k );" statement is wrong. I think this may be the cause of that 543054569 or somethig number that showed up. 'k' is only a pointer to the first element of the array, this means that you're actually printing a memory adress. If you want to print the elements of an array, you must define an index, let's say 'n' f.e., and print each element of the array in increasing order, until reaching its dimension.

Code: [Select]
int array[10];
int n;

for( n = 0; n < 10; n++ )
    printf( "%d\n", array[i] );

I personally think the code you're trying to write is out of league for the moment. You should focus on the mentioned details first.
I wrote a version of the program in C. I don't know if you'll understand it right now, but I hope it is useful to you in the future, when you have a better knowledge of the subject in matter.

This was my first reply since I registered in this forum, so I hope I helped you bit.
If you have any questions, please don't mind asking them.

Cheers.

6
C - C++ / Re: Advice on modern c project based book
« on: February 17, 2016, 12:12:21 am »
Your advice is spot on - I'm just starting, so it doesn't really matter where or how I'll start. Practical C Programming then it is!

Actually, it does matter where you start. I strongly recommend you to buy or download "The C programming languaje", by Kernighan & Ritchie. I know you probably heard of it before, or saw it in the stackoverflow-book list, but I think no one told you about its importance.

K&R (as many call it) was the first book of C, written by no other than the developers of the languaje. If you are serious about learning C and want to reach a deep knowledge of the subject, this is the right (if not only) book to start. Only after reading it and doing as many of its exercises as you can (and more), I would recommend you to continue with other C programming books. "Modern" ones, are not always the best... specially for this matter.

Pages: [1]