Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   I need some help (http://www.go4expert.com/forums/i-help-t23757/)

blackhex666 3Nov2010 20:16

I need some help
 
I have a sourcecode that is updating every day throng SVN
I want to make a program that is downloading the source code making some changes in some files and compling
i want some indications,some directions

im a begginer and this will be my first big project
i think that i need a source code for the complier
the downloading i don`t know how to do it
and i don`t know how to make the complier to complie the source code
the modifications i think its easy
you open the file,search for some rows and add the commands that you want

xpi0t0s 4Nov2010 13:34

Re: I need some help
 
How do you want to control SVN: do you want to use an API? If you know the OS commands to perform the operations you want, I don't know SVN but let's say there's a command "svn get foo.c", you could just call the system() function with exactly that string, i.e. system("svn get foo.c"); and while that won't be a high performer it is very easy to do. This is a lot easier than using an API and as this is your first big project I would suggest keeping things as easy as possible. You can always convert system() commands to API calls later on if you want, once you've got the whole program working.

> ithink that i need a source code for the complier
> and i don`t know how to make the complier to complie the source code

You won't need source code for the compiler, just call system again with the relevant commands, e.g. system("gcc foo.c -o foo.o -Wall"); There could be a compiler API but again using system means you can use the commands you're already familiar with. Just construct that string in memory then pass it to system, e.g:
Code:

char fileName[32],gccCmd[256];
strcpy(fileName,"foo");
sprintf(gccCmd,"gcc %s.c -o %s -Wall",fileName,fileName);
system(gccCmd);

> the downloading i don`t know how to do it

you need to use SVN a bit in your own projects then. Get the hang of controlling it manually, then once you're familiar with the usage you can then automate it.

> the modifications i think its easy
> you open the file,search for some rows and add the commands that you want

Should be, depends what you're looking for and what kind of changes you want to make.


HINT: a very common beginner mistake is to try to write the whole lot in one go before compiling it. Don't do that; just start simple, maybe with a function to perform an SVN GET (or whatever the command is), then make sure that compiles and runs as expected before moving onto the next bit. You can then manually do an SVN UNGET (owtci) to cancel the checkout.

Someone recently posted about 600 lines of code where they'd tried to write the whole lot before compiling it, and of course they were getting millions of errors and were totally stuck. There were simple syntax errors all over the code, including in the first few lines that they'd have got if they hadn't tried to do this. If you've only got 5 lines of code to start with then the scope of any error you get is only going to be those five lines. I've been programming since 1981 and I *always* start with a Hello World program.


All times are GMT +5.5. The time now is 01:36.