Author Topic: My first program! Permission denied  (Read 14983 times)

Offline malkavians

  • Single posting newcomer
  • *
  • Posts: 3
My first program! Permission denied
« on: October 30, 2007, 07:27:52 pm »
Hi

I've decided to learn C.  My friend lent me a beginner book, and recommended Code::Blocks.
It all installed nicely, and opens up no problem.
It's very pretty.
So I try the first example program in the book.  I'm pretty darn sure I've typed everything in *exactly* as the book did.  It's a simple thing to print a message on the screen.  I could type the code here, but I don't think that's the problem.
I click compile, and run, and a window pops up saying

sh: /home/colin/Documents/learning C/firstprogram : Permission denied

I should mention I'm running Kubuntu 6.06.
So I think my computer doesn't know whether to trust anything Code::Blocks asks it to do. 
I'm not really a linux guru, so it may be incredibly obvious, but can anyone suggest (in newbie language) a way of getting around this? It's quite disheartening.

Thanks!
 

Offline alchemist

  • Multiple posting newcomer
  • *
  • Posts: 38
    • My Blog
Re: My first program! Permission denied
« Reply #1 on: October 30, 2007, 07:58:22 pm »
Hello,

First, try to not use names with spaces within ;)

Second, can you tell us more what you did ? The book doesn't speak about Code::Blocks, so how did you interpret "exactly what the book said" ?
Kind Regards,
Xavier Miller.
http://xaviermiller.be

Offline malkavians

  • Single posting newcomer
  • *
  • Posts: 3
Re: My first program! Permission denied
« Reply #2 on: October 30, 2007, 09:12:35 pm »

Hi. 
Thanks for the quick reply.
All the book says is
"   If you were to type this programusing your C compiler's editor, compile the program, and run it, you would     see this message appear on the screen:
This C stuff is easy!  "
What I meant is that I wrote out the book's code exactly.
And it did compile, which implies to me that there aren't any problems in the code itself, but rather in the running of the compiled thingy (terminology is going to come later)

The code itself is (don't laugh, you were a beginner once):
/* Prints a message on the screen */
#include <stdio.h>
main()
{
    printf("This C stuff is easy!\n");
    return 0;
}
Thanks again


Offline XayC

  • Multiple posting newcomer
  • *
  • Posts: 94
Re: My first program! Permission denied
« Reply #3 on: October 30, 2007, 09:34:34 pm »
Hi, you may try these things:

1) Try to save the file in a directory path that has no spaces in it (like alchemist suggested). The file should have the .c extension.

2) Make sure you have the C compiler installed on your machine. The compiler is called gcc and you may check if you have it simply typing 'gcc' on the shell. If you don't have it, you can get it typing 'sudo apt-get install build-essential'.

3) Try to build one of the Code::Blocks templates, base programs known to compile correctly, to see if the problem is in your program. (File->New->Project->Console Application then follow the wizard).

Regards, XayC

Offline malkavians

  • Single posting newcomer
  • *
  • Posts: 3
Re: My first program! Permission denied
« Reply #4 on: October 30, 2007, 10:37:54 pm »

Hey, no way, that totally worked!
I changed the directory name to have no spaces.
I changed the file name to end in .c
Looking at the code that Code::Blocks generated for me, I notced it include the lines
#include<stdlib.h>
and
int main()   (rather than just main())
I'm not sure what these are, but I'll find out soon enough, I think!

And it worked!
Awesome.

Thanks so much for this help.  I might never have gotten it!