Welcome, Guest. Please login or register.

Author Topic: How to program: In one easy step... Learn?  (Read 5158 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: How to program: In one easy step... Learn?
« Reply #29 from previous page: February 19, 2003, 12:57:13 PM »
Quote

Atheist wrote:

So if I put "int argc"  as  "int 3"
It would accept up to 3  words or numbers, in addition to the name of the cammand, from the shell prompt? Or from being called from another program.



That, my good man would be a syntax error. When you define any function C (just as many other languages) the definition says only what types of variables are handed to the function, not what the allowed values are. It's up to you, when you write the guts of the function how it deals with unwanted values etc.

Quote


char*argv

This looks like you are multiplying the terms.
Or, are variable names supposed to be placed between the square brackets? I don't get it.


Unfortuantely thats C pointer syntax for you. What 'char* argv[]' actually says is 'argv is a pointer to an array of characters'.
Arrays and pointers in C are also pretty much interchangable. This means that you could also declare it as 'char** argv', which means 'argv is a pointer to pointers to characters'.
Don't worry about it too much yet though...

Here's a simple program (off the top of my head so iut may have bugs) you could try to compile...

/*
   A simple C program to show arguments passed
   to main()
*/

#include

int main(int argc, char* argv[])
{
   int i;
   puts("Here's what was passed to main()");
   for (i=0; i   {
      printf ("Argument %d was '%s\'n", i, argv);
   }
   puts ("All done!");
   return 0;
}

Assuming it works and you compiled it as testprog, try running it in a shell as follows

testprog bollocks whatever

Hopefully you'd get something like

Here's what was passed to main()
Argument 0 was 'testprog'
Argument 1 was 'bollocks'
Argument 2 was 'whatever'
All done!

as your output.

Quote

Well, at any rate, which C. People say C, C++, then there's ANSI C (and maybe ANSI C++). Is ANSI the name of a company, like Storm is?

I've always considered taking a chance at using it.


Well, ANSI is a standard (Amierican National Standards Institute). Pretty much all modern C compilers conform to this standard so don't worry. It defines a few ground rules that make sure a simple program (such as the one I did earlier) should work everywhere.
C++ is a little more of a mixed bag when it comes to standardisation.

Hope this was useful ;-)
int p; // A
 

Offline Eniodis

  • Newbie
  • *
  • Join Date: Feb 2003
  • Posts: 17
    • Show only replies by Eniodis
Re: How to program: In one easy step... Learn?
« Reply #30 on: February 19, 2003, 01:20:16 PM »
AmosPRO Compiler is the best tool to easily learn programming.

WHY ?... :-o

1) A nice & interactive Editor ! You just type, for example "print", you put your cursor under this command and press 'F1'. Immediately, you get an explanation and - very often - a small tutorial.

2) You will quickly check the whole possibilities of programming (sprites, graphics, ...)

3) A lot of tutorials on the Aminet

But... You must work on a Pal Screen :-(

Eniodis
 

Offline DaveP

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2116
    • Show only replies by DaveP
Re: How to program: In one easy step... Learn?
« Reply #31 on: February 19, 2003, 01:46:26 PM »
Quote

DaveP wrote:
It defines the entrypoint to your program. void means
no arguments are supplied. The real signature is

int main( int argc, char*argv[] )

where argc is the argument count and argv is an
array of the strings passed to the program on invocation.

No. The signature for main passes in the parameters
argc and argv into your program. In AMOS would you
define a procedure having an variable called 3? In fact
can you even do procedures properly in AMOS yet or
do you have to resort to GLOBAL ?

Quote

It would accept up to 3  words or numbers, in addition to the name of the cammand, from the shell prompt? Or from being called from another program.

It can be called from another program sure enough, but what it
does is tell you in argc how many arguments have been provided
and argv is an array of the strings that have been provided. You
cannot limit what people type into a console. So your program if
you wanted to restrict to just 3 args would say:

int main( int argc, char * argv[] )
{
     if ( argc > 3 )
     {
   return -1;
     }


Quote

char*argv

This looks like you are multiplying the terms.
Or, are variable names supposed to be placed between the square brackets? I don't get it.

In this context, given it is a procedure/function declaration
its a pointer reference. So argv is a pointer to a character array.

Havent got time to answer the rest just yet.
Hate figure. :lol:
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: How to program: In one easy step... Learn?
« Reply #32 on: February 19, 2003, 02:01:54 PM »
Quote

Eniodis wrote:
...
But... You must work on a Pal Screen :-(

Eniodis


...and nothing you ever write will work the moment you shove an accelerator, extra memory, hard disk, change your workbench pattern prefs (joke) etc.

Seriously though, if you want to go along a BASIC route, there are much better implementations available than any incarnation of AMOS I ever saw.
True the editor may be user friendly but there are plenty of source editors available that are just as, if not more  powerful.

Ok, I promise not to keep flaming AMOS ;-)
int p; // A
 

Offline Atheist

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 820
    • Show only replies by Atheist
Re: How to program: In one easy step... Learn?
« Reply #33 on: February 20, 2003, 07:00:33 AM »
Quote

Karlos wrote:

...and nothing you ever write will work the moment you shove an accelerator, extra memory, hard disk,


I don't know what you mean by the extra memory. Amos worked when I only had chip ram, and it worked when I got both. I don't have the compiler thogh, but am getting it soon. I know it's free, but I found a store that had it on the original disks, and am waiting to see if it's still available. (Professional Comp)

Are you saying that when Amos Professional, compiles a program, it won't work on what 020, 030...?

If Francois Lionet created a new "library", could it compile to the G4's?

Amiga! Aminet 2.0(4.0) is coming!
\\"Which would you buy? The Crappy A1200, 15 years out of date... or the Mobile Phone that I have?\\" -- bloodline
So I guess that A500, 600, 1000, 2000, CDTV, CD32, are pure garbage then? Thanks for posting here.
 

Offline Atheist

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 820
    • Show only replies by Atheist
Re: How to program: In one easy step... Learn?
« Reply #34 on: February 20, 2003, 07:22:33 AM »
@ Karlos

1) I find it surprising that the first string is the name of the program itself. Was that correct?

2) I don't get this stuff; I see
For____without a___next
Return___without a____gosub
Return 0____0 what?

You see, it's too cryptic, I didnt' know "argc" was a name for a number, and that I could have put in its place "word_number". I did realize it meant integer though.

3)i++____increment by 1
i++2_____increment by 2?

4) So, is there an ANSI C++?
\\"Which would you buy? The Crappy A1200, 15 years out of date... or the Mobile Phone that I have?\\" -- bloodline
So I guess that A500, 600, 1000, 2000, CDTV, CD32, are pure garbage then? Thanks for posting here.
 

Offline Atheist

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 820
    • Show only replies by Atheist
Re: How to program: In one easy step... Learn?
« Reply #35 on: February 20, 2003, 07:36:58 AM »
Quote

Karlos wrote:

   puts ("All done!");
Quote


Why were you using
Printf("text")

Then

Puts("Text")

???


argv[]____could I have used____word[]
\\"Which would you buy? The Crappy A1200, 15 years out of date... or the Mobile Phone that I have?\\" -- bloodline
So I guess that A500, 600, 1000, 2000, CDTV, CD32, are pure garbage then? Thanks for posting here.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: How to program: In one easy step... Learn?
« Reply #36 on: February 20, 2003, 09:46:50 AM »
Quote

Atheist wrote:

I don't know what you mean by the extra memory. Amos worked when I only had chip ram, and it worked when I got both. I don't have the compiler thogh, but am getting it soon. I know it's free, but I found a store that had it on the original disks, and am waiting to see if it's still available. (Professional Comp)

Are you saying that when Amos Professional, compiles a program, it won't work on what 020, 030...?



Basically, my experience of AMOS has not been a good one. Any Amos program I've ran, be it old custom-chip hacky game style or intuition friendly has fell over at the slightest provocation.
This has been the case on at least three accelerated systems I used (030, 040 and 040/PPC). And yes, one program that used to work in 16Mb 70ns ram crashed continually with 64Mb 60ns ram. Maybe the speed was too much for it, but I don't know. When the machine just restarts on you, you don't get much debug info ;-)

-edit-

Anyhow, me old mate, back to C (neary forgot to answer your other questions)

First off, the first string argument passed to the C main() function is indeed the program name. You didn't misread that.

As for argv, you could indeed have changed the name to 'word' or whatever you wish, just as long as you use the same name in the code, eg

int main(int numberOfArguments, char* argumentString[])
{
/* use numberOfArguments and argumentString
somewhere in here*/
}

would be perfectly OK. It's just that 'argn' and 'argv' are kinda conventional.

As for output, I did use puts() and printf(). There is a reason for this.
Basically puts() is your no-frills console output command that writes a string, complete with a newline ('\n') character on the end. Thats all it can do.
The other function, printf() is a complex beastie that can print formatted strings (hence the 'f' in printf).
Going into the detail of formatted output would take ages. But, just to give an idea:
The string we pass to printf() can embed special codes, prefixed with a percent sign. When the printf() function finds one of these, it substitutes it with the corresponding argument. For example

printf("An integer : %i\nA float : %f\n", 10, 5.5);

should produce the following

An integer : 10
A float : 5.5

as output. There are options that pad, justify, enforce sign, notation conventions etc.

As a final point, printf() doesn't stick a newline on the end of a string by default like puts() does, so you'll see I had to stick the '\n' character in the string myself.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: How to program: In one easy step... Learn?
« Reply #37 on: February 20, 2003, 10:48:48 AM »
Hi again,

Quote

Atheist wrote:
@ Karlos

1) I find it surprising that the first string is the name of the program itself. Was that correct?

2) I don't get this stuff; I see
For____without a___next
Return___without a____gosub
Return 0____0 what?

You see, it's too cryptic, I didnt' know "argc" was a name for a number, and that I could have put in its place "word_number". I did realize it meant integer though.

3)i++____increment by 1
i++2_____increment by 2?

4) So, is there an ANSI C++?


1) Yep its true - I think I detailed that in the last post. The name of the executable you ran in the shell is passed as the first string. This implies that there is always at least one string passed to main, so the value of 'argc' should always be at least 1.

2) For/Next
In C/C++/Java, your basic For/Next loop construct has the following syntax

for (; ; )
{

}

sets up the inital values etc in the loop. We can initalise counters and stuff here.

is the criteria that must be true to continue looping.

is an event to do in each loop (usually increase your counter etc).

is the code to execute in each loop.

There is no 'Next', basically everything between '{' and '}' is inside the loop.

Return without a gosub / return 0 what?

Fair point. What you have to think in C is that code exists only inside of functions. So our main program is inside of a function main(), as you saw already. That function is ultimately called by the operating system when you run the program. The return you see goes back to whatever ran the program.
We used 'return 0' because our definition of main() stated that it returns an integer number :

int main(int argn, char* argv[])
{
return 0;
}

Zero is just a nice safe number to return from main. You could return any integer number you wanted. The meaning of the value is operating system dependent. If you returned the value 5, for example, AmigaDOS would regard that a warning.

3) i++ etc..

Welcome to the world of laziness that is C. C was designed to compile into efficient machine code. It so happens that many CPUs can quickly increment and decrement variables and the above operator syntax reflects this ability.

C/C++/Java have a wealth of operate-assign operations. Basically, any dyadic (takes two arguments) arithmetic/logic operation can be written in an operate-assign shorthand for operations like i = i x;

So, to elaborate

i = i + 2 becomes i += 2
i = i * 3 becomes i *= 3
i = i / x becomes i /= x
i = i & 15 becomes i &= 15

etc.

Which you prefer is up to you. Modern compilers almost always optimise the former syntax to the latter during compilation if it can give faster code.

When you see i++, i--, this is a special case syntax for increment/decrement by 1. I should point out that prefix and postfix versions exist:

i++, ++i
i--, --i

What's the difference? The prefix versions (++i) change the value of i first and the new value becomes the result of the whole expression. The postfix versions (i--) do the same job, but the previous value of i is the result of the whole expression

Well an example is best

a)

int i = 5
int j;

j = ++i;

Here, i == 6 and j == 6

b)

int i = 5;
int j;

j = i++;

Here, i == 6 and j == 5;

c)

int i = 5;
int j;

j = --i;

Here, i == 4 and j == 4

You get the idea.

4) ANSI C++

Yes, indeed there is. Unfortunately, C++ is a rather more complex beast and has many features C does not. An inevitable upshot of this is that the defined ANSI C++ standard is not uniformly supported everywhere. If you do get into this, things to watch out for when developing code are

1) STL implementation
2) namespaces
3) templates
4) abstract base references

int p; // A
 

Offline Atheist

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 820
    • Show only replies by Atheist
Re: How to program: In one easy step... Learn?
« Reply #38 on: February 21, 2003, 03:42:15 AM »
@ Karlos
Well, this is interesting. I understood all the things you said. I've yet to see a book that actually spells it out like that. It seems to me it was deliberately made that way to keep people away from programming.

Like, they could have structured it
For x=1 to 6 step 1
Print X
Next x

instead, and the compiler would just work it out. I can read the above code.

The answer to 1 is really neat, it means you could check to see if someone renamed your program. Sometimes you need to know everthing.

Thanks for the output. Obviously I'm not going to learn C on a message board, but one last important thing.

1) Have every type of C (C, C++, ANSI C and ANSI C ++) been made for Amiga?

2) No RKM's (books) are available for 4.0. Now no custom chips exist. So, the libs: directory will be completely rebuilt for the G4. Do you need 2 different compilers, one for G3, and 1 for G4?

3) I suppose I would need to buy an SDK to get that library information, before I could program in (any) C?

4) Does one need RKMs to program in ADos 1.3, 2.04 etc.? Can you make 1 program, that will take advantage of a CPU, whether it's just a 68000, or  a 68030 etc.? Or are separate versions always needed?

We REALLY need to stay with 1 CPU.

For instance, now a C is needed to access the altivec component of CPU's.

Amiga!
\\"Which would you buy? The Crappy A1200, 15 years out of date... or the Mobile Phone that I have?\\" -- bloodline
So I guess that A500, 600, 1000, 2000, CDTV, CD32, are pure garbage then? Thanks for posting here.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: How to program: In one easy step... Learn?
« Reply #39 on: February 21, 2003, 09:57:05 AM »
Hi again,

Quote

Atheist wrote:
@ Karlos
Well, this is interesting. I understood all the things you said. I've yet to see a book that actually spells it out like that. It seems to me it was deliberately made that way to keep people away from programming.


I'm glad you found it useful. C isn't the nicest language for beginners. The syntax looks weird at first but it really is worth the time to get to know it. It's a structured language and you eventually come to understand and even appreciate the layout. Then BASIC ends up looking weird ;-)

Quote

Like, they could have structured it
For x=1 to 6 step 1
Print X
Next x

instead, and the compiler would just work it out. I can read the above code.


Well, after a bit, you come to realise that the C style  looping mechanisms are unsurpassed in flexibility.
The basic 'use a counter' style looping is just the start. You can create much fancier loops that can iterate through lists of objects without needing a coutner or even knowing the number of objects.
But, that's something for a much later tutorial ;-)

Quote

The answer to 1 is really neat, it means you could check to see if someone renamed your program. Sometimes you need to know everthing.


I suppose you could. Here's an example that might work

/* get io functions */
#include

/* get string functions */
#include

/* a global string that holds the program name */
char realName[] = "atheistsprog";

int main(int argn, char* argv[])
{
/*
* the stricmp() function compares two strings
* (case insensitive) and returns 0 if they are
* equivalent.
*/
  if (stricmp(realName, argv[0])!=0)
  {
    puts("You changed the program name!\nRename it back");
    return 5; /* 5 is an AmigaDOS warning */
  }
  puts("OK");
  return 0; /* okey dokey */
}

Quote

Thanks for the output. Obviously I'm not going to learn C on a message board, but one last important thing.

1) Have every type of C (C, C++, ANSI C and ANSI C ++) been made for Amiga?


Pretty much. If you just want to learn (ANSI) C for starters, get hold of the amiga developer cd v2.1. It comes bundled with StormC v3. Its even good to get the basic fundamentals of C++ too, but one thing at a time.

I know I gripe endlessly about StormC's C++ support being crap, but for an easy working environment its lovely. Just what you don't want to be doing is diving straight into CLI based compilers and makescripts etc. StormC's interface hides all that away nicely.

Once youre exprerienced with the language(s) and want the full works, go GCC.

Quote

2) No RKM's (books) are available for 4.0. Now no custom chips exist. So, the libs: directory will be completely rebuilt for the G4. Do you need 2 different compilers, one for G3, and 1 for G4?


Don't worry on that front. The G3 and G4 are code compatible. G3 code will run on G4, your only difference is that Altivec stuff will only run on G4 (and above?). Anhow, you can expect that your PPC compiler will support multiple target architectures.

The language itself doesn't change, thats the beauty.

Quote

3) I suppose I would need to buy an SDK to get that library information, before I could program in (any) C?


No. If you just want to write simple, portable programs to learn the language, you dont need the full OS related stuff.
Any ANSI C compiler and some tutorials will suffice.

Quote

4) Does one need RKMs to program in ADos 1.3, 2.04 etc.? Can you make 1 program, that will take advantage of a CPU, whether it's just a 68000, or  a 68030 etc.? Or are separate versions always needed?


The RKMs are very handy when you need to write Amiga specific stuff. They detail how the OS works internally and gives you all the required info to take advantage of stuff like gfx/sound/threads etc.
The developer cd comes with those too ;-)

As for code generation, if you need to optimise a program as well as possible then you will need to target a given CPU. Sad fact of life. Unless you have used some assembly code in your project, you won't have to change any code though ;-)

With experience, you can write several versions of your critical functions (usually in assembly) and detect which CPU is used at runtime, then use that information to call the 'optimised' code.

Quote

We REALLY need to stay with 1 CPU.

For instance, now a C is needed to access the altivec component of CPU's.

Amiga!


Well, that's what compilers and libraries are for. The language itself doesn't need to change to take advantage of these developments. That's one of the real beauties of the language and one reason why it's stayed around for so long!
For example, suppose a code did something like

a = b*c+d;

where a, b, c and d are floats. Compiled for 680x0, we'd expect a 'fmul', 'fadd'and a few 'fmove' instructions.
On a PPC 60x, a good compiler would recognise the construct and use the single multiply-add instruction that the PPC supports.
With Altivec, a good compiler will be able to optimise code that operates on arrays of data etc. to make use of the altivec unit.

Tune in next week for the next thrilling installment!

:-)
int p; // A
 

Offline Crumb

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 1786
  • Country: 00
    • Show only replies by Crumb
    • http://cuaz.sourceforge.net
Re: How to program: In one easy step... Learn?
« Reply #40 on: February 21, 2003, 05:48:07 PM »
@FuZion
As DaveP has said, it would be a good idea to start learning ARexx. And I say ARexx and no other scripting language because in Amiga almost every serious program as an ARexx port, so it's quite interesting to automatize tasks.

Once you have some control over ARexx I would try to learn C. No C++ but C. It integrates better with AmigaOS and to learn C++ it's better to know C.

If you find that you need more speed and control try some asm. I don't advise you to go directly to asm because it will be even more frustrating that C, you will probably crash your computer a lot more.

I wouldn't use Pascal (although I used it for some practices) because C is faster, has better support and integrates better with AmigaOS

Keep away of any Basic, it integrates bad with AmigaOS and usually makes the programmer used to bad habits (like GOTOs).

For me Java is not an option because in Amiga there's no Java (ok, it's so slow that it's nearly unusable and the versions that use graphics are alphas). Just look at the number of Amiga apps/games written in Java. None. Ok, if you aren't interested in coding for fun on your Amiga and want to make some money Java may be interesting.

@Atheist:
the right ANSI C (that is the official C standard) hello world would be:
#include
int main(void)
{
printf("Hello ANSI C world!\n");
return(0);
}

you write that main returns an int, because ideally you should always indicate to the OS how your program has finished (if an error has ocurred etc...).

You put the stdio because you are going to use the printf() function. You may select not to use that function at all. If you have 2 million of functions would you want your compiler to check everything for you? That would be damn slow (basic comes to my mind).

You use ";" because you can do long complex sentences that take up various lines.

And no... loops don't require includes, you can use "while"s, "for"s "if"s etc... without adding a single include. In fact you may do everything without using includes at all, just using pointers, but that would be pointless.

printf uses () because it's a function. It logical, everything you use are functions.

Why you use " in basic instead of for example º ???
its just a convention and that is what you do in C.
Why basic doesn't recognize that I want to show a line if I only write "Hello" instead of writting print"hello" that's illogical from your point of view.
That are language standards.
C is logical, well structured and used to learn structured programming, in contrast Basic is not so structured by definition, is slow and doesn't integrate so well with AmigaOS.

The only other language that integrates so well with AmigaOS is Assembler.

Every Basic sucks. If you don't want to learn C, at least learn Pascal, learning Pascal you may learn how to program correctly, with AMOS I'm sure you won't. Amos is quite incompatible with the OS, doesn't allow you to use third party libraries in a comfortable way (just try to use Warp3D from AMOS for example)... and yes, I used Basic when I didn't have a clue about programming, with c64, cpc and msx, but I wouldn't recommend it.

ARexx, C or ASM, that are the options for me in AMiga. And C++ to create some things, but I wouldn't suggest using Basic at all.

Simple fact: big apps/games aren't done in AMOS, they are done using C/C++ or even ASM, but these apps/games never are done using any Basic reincarnation.

Definitely... learn C before complaining so much  about it. You can use C without pointers but one of the most powerful possibilities of C is using pointers.

And other advantage of C you only have to learn very few things to learn C. The rest are extensions that work following the standards.  I recommend the Kerningan&Ritchie C book.

I think that argc stands from argument count...
but that is well explained in the K&R book. If you want to use graphic functions just load an autodoc viewer and do Amiga-M, you will have a list of functions with its input and output.

Just read a book about C, then you will be ready to code in C. Don't expect to use it even at 10% without any documentation... Use the sidewinder tutorial to set up a C environment and then start to read a book and do type some examples...

You won't do impressive stuff the first day, but once you have some experience you will be able to do things impossible to do in C. I would say the same if you started with ASM, without experience you won't do impressive stuff.

for me the following loop is not flexible:
for i=1 to 10 step 1
whatever
next i

why can't I for example multiply the variable each time? or why can't the for() increase 2 variables? and three? and four? Why do I have to write next if I have indicated in the for that I'm going to increase C?
wouldn't be easier to put
for i=1 to 10 step 1
{
whatever
}
why do I have to write "to"? it's obious that the goal is the 10 so why write that "to"
and why can't I use multiplication or divisions or simply do various things each time?
for i=1 10 i=i+1
let's order it a bit...
for i=1;10;i=i+1
and why it has to be that number? why can't I put other conditions, why I don't use the condition as a while condition to make it more flexible?
for i=1,j=2; i<11;i=i+1,j=j-1
why should I type i=i+1 to increment my variable? Wouldn't be faster to write that I want to increment the variable? isn't faster to write variablename and ++ or --?
for i=1,j=2;i<11;i++,j--
isn't it logical and flexible?
and to make it look cleaner and define better where the for ends why not put ()?:
for(i=1,j=2;i<11;i++,j--)
what do we have? oh yes a C "for" loop.
Firstly you put what you want to do the first time you enter the "for", then you type the condition of being inside the loop and at the end you put what it has to do each time. Quite logical in my opinion. With Basic if your code was big and you had two nested "for"s you would have to check that you have put next i and next j in the right positions (whyyy???) with c you don't have to worry about it and you simply put two "}"

Just learn C before complaining so much about it and saying that it's designed to keep people away of programming. Programmers read books, you know... if you want something scary try to learn ASM. Even better, try some 8086 asm instead of 68000... you will see something really scary then ;D
The only spanish amiga news web page/club: Club de Usuarios de Amiga de Zaragoza (CUAZ)
 

Offline FuZionTopic starter

  • Full Member
  • ***
  • Join Date: Jul 2002
  • Posts: 223
    • Show only replies by FuZion
    • http://www.deceptiveaudio.co.uk
Re: How to program: In one easy step... Learn?
« Reply #41 on: February 21, 2003, 06:28:34 PM »
This is looking more daunting as the thread grows :-o
 

Offline iamaboringperson

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 5744
    • Show only replies by iamaboringperson
Re: How to program: In one easy step... Learn?
« Reply #42 on: February 21, 2003, 08:34:08 PM »
Quote

FuZion wrote:
This is looking more daunting as the thread grows :-o

NO! C++ & C are good! they are quite easy

nobody should be 'studying' basic because they are afraid C might be a bit too hard for them
C is a powerefull, professonal, high-performance, structured language - it is serious

but its also easy to use - it is IT IS!
you just need practice & patience & time
forget about basic - throw it away! that crap only tought me bad habbits - which, for a while caused me to program in C badly - i gained little out of basic programming, well, nothing that i would of done better in c    (?)

grab a good book on C, set up your c compiler, and start practicing