Thanks for the guide!
I've just found why i can't use getbalance() as a local variable. At least at one point.
the code:
if(iterate(balance, (guess / 1200), 0, payment_fixed, 0) <...
Type: Posts; User: AmbliKai
Thanks for the guide!
I've just found why i can't use getbalance() as a local variable. At least at one point.
the code:
if(iterate(balance, (guess / 1200), 0, payment_fixed, 0) <...
Yeah, i'm kinda new to this and self taught, i tried to indent it but i'm probably not really getting the idea! Could you suggest how to do it properly? (i should really have a search on the net!)If...
I had something similar originally. But i thought i'd need a global variable otherwise it would keep asking for input whenever the function was called. So i defined a global variable and used that...
Thanks for the reply!!
Its things like that which make me realise how new i am to this!
I've done something similar to your idea now, with a while loop in main.
So my code is now:
...
2 really good ideas! Thanks!
I don't know how i would make the program go back to the beginning though?
Put the whole thing in a while loop? But would each case in the switch have to set a flag...
Ok, just as i thought, i was being a bit daft with my function calls. Instead of doing:
float getbalance(void)
{
float balance;
printf("Enter balance.\n");
scanf("%f",...
Ok thanks!
I hope people will have a brief look:
#include<stdio.h>
float getbalance(void)
{
float balance;
Hi everyone, as an aside to the sudoku thing i was trying, i wrote a program to calculate various aspects of a debt. (It was mainly an exercise in using functions)
Anyway, it works and i think i'm...
Thanks for the replys guys.
I think maybe its too difficult at the moment to have a dynamic array. I don't even know where to begin with that!!
I'll stick to a fixed array and see how i get on...
Ah ok, i think i understand. So malloc() isn't a way to access the array directly, just a method to reserve enough dynamic memory to the potential array?
So as a simple example... if i did:
...
Thanks!
I started it purely as a learning exercise. I don't see the point in following tutorials etc unless you're actually using the code in a problem. So i set myself a problem and set about...
Wow, replying quicker than i can type! Thanks!
So then how would i refer to specific parts of the array?
int *board;
board = malloc(width * width * 9);
Well the board would be width x width in size and each square would have a maximum of 9 possibilities.
Thats how i was going to store the values. Is there a better way do you think?
Also i...
Hi everyone,
A while ago i wrote a program to solve a sudoku board by way of learning to program in C. It worked and i learned a lot (and caught the bug!)
Now i'm looking at improving it.
...
Ah thanks! You're a legend!
Interestingly, i had it as char selection; to begin with but that wouldn't work so changed it to int.
Thanks a lot!
Kai.
Hi guys,
I was just writing a wee program to calulate APR on a credit card, i was going to use a case statement, so did a bit of reading and looked at some examples, seems simple but i can't get...
Thanks for your reply,
Tha part where i set x is because i want the array (i.e the number of inputs) to be any size. Thats why i tried inputs[x]. I set x just because i wanted to get the gist of...
Hi everyone, its been a while since i last posted, i started teaching myself C a while ago and i'm trying to get back to it. Been really busy at work with fun languages like Ocean!
Anyway, i like...
Thanks a lot for your help but i've abandoned it! Really in the spirit of learning! ;)
Did it with a bash script instead.
Cheers
it doesn't seem to keeo the shell variables. Even if i stick to bourne shell. ie:
system("W_DIR=2amp/eps/3m6to10m; export W_DIR");
The variable is forgotten directly after the above command!
Thanks, i tried saving the path info in variables but i can't seem to get it to work. I'm using tcsh and the c program seems to be implementing all my system calls in bourne shell. How do i change it...
Hi Everyone. I'm having problems with system calls, basically the commands that i can put into my terminal are fine but don't work as system calls from c.
I'm using tcsh.
In other words:
(23)...
Hi Everyone, its been a little while since i posted, been lurking though!
I'm writing a short program to try and sift through a mountain of data from some simulation results.
Basically, the...
so i'd be as well just typing it out each time?
There are a lot of places in my program where i use the above construct. with code sometimes after x or y etc.
Its not bad programming practice to...
I don't even know how to use function pointers! Think i'll stick to macros just now!
I've already started converting my program over to using macros! :D