Hey guys, I just started learning C after I finished reading the book " Learn Python the hard way". I've been following tutorials from cprogramming.com but some examples are giving me errors on xcode. I'm unfamiliar with xcode as I used VIM for python. My question is, how do I compile code on xcode but run it on terminal? I tried dragging and dropping the product onto the terminal but it doesn't run. Also, does anyone know a good tutorial for OOP? I need to familiarize myself with it more. For example, this program from cprogramming.com does not give an output when ran on Xcode:
Code:
#include <stdio.h>
struct xampl {
int x;
};
int main()
{
struct xampl structure;
struct xampl *ptr;
structure.x = 12;
ptr = &structure; /* Yes, you need the & when dealing with
structures and using pointers to them*/
printf( "%d\n", ptr->x ); /* The -> acts somewhat like the * when
does when it is used with pointers
It says, get whatever is at that memory
address Not "get what that memory address
is"*/
getchar();
}
Last edited by a moderator: