Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

debacle

macrumors newbie
Original poster
Oct 9, 2007
6
0
Hey!

So I'm following this C-tutorial, and made a very simple programme. Xcode compiles it without a problem (or at least it says "Build succeeded"), but wont "build and run"! Why? I really want to run it, even though it might be sort of a pointless application. :)

Here's the code:

#include
<stdio.h>

int main ()
{
printf( "Apa? Apa!\n" );
getchar();
return 0;
}
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Did you just create a C file and open it in XCode or did you create a new XCode project? XCode only enables the run options on XCode projects.
 

debacle

macrumors newbie
Original poster
Oct 9, 2007
6
0
I created a new project, then I opened a .c-file in it - that might be the problem? For some reason I couldn't get the editor to open without doing that..? It just said "no editor" in the white field (hence I got frustrated, wrote it in a reg text editor and opened the .c-file inside the project).

It says "project1.c" (obviously name of project) in the frame-thingie on the left, but "first.c" (name of opened file) above the edited code (on the small.. eh gray trim there).


(Sorry about poor choice of words; english is my third language)
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
I think you need the code in project1.c. If you double click on project1.c it should open the file in a new window and you can just paste your code in there...
 

debacle

macrumors newbie
Original poster
Oct 9, 2007
6
0
Hmm, if I double click project1.c a window called "info" comes up, where the only place I can type at says "Comments:" - is that really correct? I tried to paste my code there (hmm, all black too, not like when i typed in the other file when some parts were red, some blue etc; sort of practical) I can also only build, not build and go (I did save after I put the code there, btw). :(
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Nope, comments is for comments about the file, not for code. It sounds like you are in a different editor mode to the one I use. When I double click I file I get an editor.
 

debacle

macrumors newbie
Original poster
Oct 9, 2007
6
0
Yeah I kind of thought so too..

I suppose I am, this all seems sort of odd. :/ I pretty much just installed xcode, one could think I should be able to edit the code Somewhere. :p
 

debacle

macrumors newbie
Original poster
Oct 9, 2007
6
0
Thank you!

Yeah.. For some reason it seems I cannot open the editor unless I open another file, even if I press the "editor" button it just says "no editor".. Think I might be missing something crucial. :p
 

debacle

macrumors newbie
Original poster
Oct 9, 2007
6
0
Got it working now. Read some. When you choose an empty project you have to create a file inside it ant write in that one.. so now I've got project1 with project1.c in it.. I can open the editor by pressing the button or pressing project1.c.. But now I can't neither compile nor compile & run! :(
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Probably because you don't have a target to compile or run. It's easier to start with a project pre-defined with targets etc. Try to creating a command-line tool project...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.