Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who's Online
1 user(s) are online (1 user(s) are browsing Forum)

Members: 0
Guests: 1

more...

Browsing this Thread:   1 Anonymous Users



(1) 2 »


No Account
Let`s learn how to code in C!
Guest_No Account
Hello I have written a small Addition Program for Amiga Computers.. I managed that it runs with Integer but I don't know how to manage float Operations with vbcc!

This Code works:

#include <stdio.h>
int main(void) {
  
int aint bint res;
  
printf("\n\nWelcome to Amiga Micro Add V.0.0.1\n\n"); 
  
printf("\nPlease enter a Number for Addition : ");
  
scanf("%d",&a);
  
printf("\nPlease enter a second Number for Addition: ");
  
scanf("%d",&b);
  
res b;
  
printf("\nThe result is: %d\n"res);
  return 
0;
}


But this don't:

#include <stdio.h>
#include <stdlib.h>
int main(void) {
  
float afloat bfloat res;
  
printf("\n\nWelcome to Amiga Micro Add V.0.0.2\n\n");
  
printf("\nPlease enter a Number for Addition : ");
  
scanf("%f",&a); printf("\nPlease enter a second Number for Addition: ");
  
scanf("%f",&b);
  
res b;
  
printf("\nThe result is: %f\n"res);
  return 
0;
}


The VBCC Compiler complains: Error 21 Reference to undefined symbol __ieees2d. vlink error

I did it with WinUAE configured with a 68040 CPU!

Posted on: 6/16 15:34

Edited by AROS-Confidence1 on 2018/6/16 17:27:13
Transfer the post to other applications Transfer


No Account
Re: Trying to learn how to Code!
Guest_No Account
Solved!

Both Codes are correct!

I found the Error you have to compile with the -lmieee Option

Compile Command:
vc -o microadd.exe microadd.c -lmieee

then it works!

Posted on: 6/16 16:01
Transfer the post to other applications Transfer


No Account
Re: Trying to learn how to Code!
Guest_No Account
Bump! *lol*

I have no clue how to solve that!
I can enter Numbers in the format 3.14 but I don't know how to code it that I can enter 3,14 in german format!

I have a friend that teaches me a little!

If others here want to learn how to Program in c.. they can install vbcc Compiler on Amiga OS 3.1 and WinUAE and use this thread for Discussion!

Posted on: 6/16 17:09
Transfer the post to other applications Transfer


Re: Let`s learn how to code in C!

Joined:
2010/10/7 15:30
Group:
Member
Posts: 728
Offline
Cool.
I hope it goes well.

Posted on: 6/16 21:11
_________________
http://www.hollywood-mal.com/
Transfer the post to other applications Transfer


Re: Let`s learn how to code in C!

Joined:
5/29 10:12
From England
Group:
Member
Posts: 65
Offline
The C compiler does not understand different human languages, only it's own - the C language. In C a float has a '.' for the decimal point, as it does in maths in general so I'm afraid that if you want to add two floats you need to enter them with the dot for the decimal place.

So, how do you handle the different language formats for numbers (called a Locale)?

You need to enter the value as a string or more technically an array of chars and then YOU have to process that string to convert it to the standard numeric format that the compiler is expecting to receive. There will be more than 1 way to do that, you could do it manually by looping over the string to replace the ',' with a '.' and then convert the string to a number, or no doubt there are library functions in the C language that will convert the string to a float taking into account the input locale (I genuinely don't know off hand). But the point is, if you want to enter two numbers in your own locale you will have to convert them. The C compiler won't understand them as-is.

If you are serious about learning C then I would highly recommend buying a copy of "The C Programming Language" by Brian Kernighan and Dennis Ritchie (RIP). It is widely respected as the "go-to" book on the subject. I bought a copy when I was at night school in the mid 90's and it is still next to my desk all these years later.

There are some aspects of C that will likely fry your brain at first (pointers and the like). If you're really lucky you'll get it quickly, if not, having the book handy will be helpful. I need it around from time to time because at the moment I do not work in C for a living (I used to around 2000 and also from 2012 - 2016). I also do not know if there are translated versions in, for example German or if that is even a problem?

Posted on: 6/17 10:28
Transfer the post to other applications Transfer


No Account
Re: Let`s learn how to code in C!
Guest_No Account
Actually I don't have much money to buy expensive Books!

But google is your friend:

https://www.google.de/search?q=C+Codin ... &sourceid=chrome&ie=UTF-8

Posted on: 6/17 13:33
Transfer the post to other applications Transfer


Re: Let`s learn how to code in C!

Joined:
5/29 10:12
From England
Group:
Member
Posts: 65
Offline
Err, if you enter "the c programming language kernighan" into our friend google, you might find that assuming you get the same results as me, the second link is not expensive at all !!

Whether it is entirely legal or not is not for me to judge or condone one way or another - just passing on what google is giving.

[EDIT] But you are correct, in paperback, I do remember it being a lot of money for me back when i was in my late 20's - probably explains why i laminated the covers and looked after it all this time.

Posted on: 6/17 15:00
Transfer the post to other applications Transfer


Re: Let`s learn how to code in C!

Joined:
2010/10/7 15:30
Group:
Member
Posts: 728
Offline
Does the K and R book go into depth about the C language?

Posted on: 6/17 16:21
_________________
http://www.hollywood-mal.com/
Transfer the post to other applications Transfer


Re: Let`s learn how to code in C!

Joined:
5/29 10:12
From England
Group:
Member
Posts: 65
Offline
How much depth do you want to go into? It alone is not going to give you the knowledge to work on an OS, that's for sure, but that's always the battle and nothing to do with knowing a language. Programming languages themselves are usually relatively easy to learn. Sure there are always complex parts and subjects like pointers, generics and so on (I'm mixing languages here), but the basic language is usually quite straightforward. It get's complex when you have the syntax nailed and want to know how you can do stuff. Then you need to know your subject. Libraries, API's, hardware, how things work and so on.

Anyway, getting back on-topic, the book I mention covers all the bases from a C syntax perspective, delves into some of the more complex topics, structures, pointers,function pointers, linked lists, types, unions, etc.

It also goes over the standard library and some of the usual things you will need like file I/O and stuff. It seems to have a section at the end on UNIX for some reason - file descriptors, I/O etc.

I should probably say that I've never read it as a book. I don't think I've ever read a programming book cover to cover, they are simply not that exciting whoever the author! I used it as a reference when attending night class and go back to it when I need a refresher on something. Usually either recursive include files or pointers because as someone that dips in and out of C, they are the things I tend to forget.

What it will NOT tell you, is how build systems work, how make and meta-make work, GCC and so on. It probably covers how to compile something - I don't recall, back then we were using some MS-DOS based environment. But that's not strictly part of the C "language" as such.

Posted on: 6/17 18:20
Transfer the post to other applications Transfer


Re: Let`s learn how to code in C!

Joined:
2010/10/7 15:30
Group:
Member
Posts: 728
Offline
I do have programming books from school, C and C++.
I have done pointers, talk about love hate.

There is a project I want to do but do not know when I will get around to it.

Basic is still a fun language to me. I have seen both Foss and commercial versions.

Posted on: 6/17 19:51
_________________
http://www.hollywood-mal.com/
Transfer the post to other applications Transfer



(1) 2 »



You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
4439
2 magorium
magorium
4095
3 nikolaos
nikolaos
4075
4 phoenixkonsole
phoenixkonsole
3941
5 deadwood
deadwood
2917
6 ncafferkey
ncafferkey
2807
7 mazze
mazze
2222
8 clusteruk
clusteruk
2112
9 damocles
damocles
1789
10 BSzili
BSzili
1516
© 2004-2018 AROS Exec