Cool. Thanks Dave. Something new to learn :)
Type: Posts; User: Baaaah!
Cool. Thanks Dave. Something new to learn :)
If I have an array containing a string:
char line[] = "My name happens to be Foo.";
Is there a way to read each string from the array i.e 'My' then 'name' etc? Or can I only grab...
It's not due to this is it?
click here
I think it depends on how much previous experience of programming you have. 'C for Dummies' is good if you know absolutely squat - and I'm talking about not even knowing what a variable is - it's...
You could perhaps try this:
while((c = fscanf(fptr,"%s", a)) != EOF)
Note the additional brackets around the fscanf() function. This will force fscanf to be executed first and pass a...
:p if only that were true.
Thanks for the responses. I get most of it - not all :). It's clearer than before anyway.
kungtotte - ah I see, thanks :) . Is there a way to stop it writing into unallocated memory?
The compiler I'm using is MinGW. I've just tried it with the Digital Mars complier and it works with that as well. Confused.
I've been trying to learn a bit about dynamic allocation in my noobish way, and I decided to see what would happen if I deliberately tried to cram too much data into a memory block that is too small...
I've messed with it a bit. I can't get it to print out the float value correctly though.
#include <stdio.h>
#include <math.h>
#define size 10
void print(float a[]);
Unless I just can't see it, you don't actually appear to have called your print() function at any point in main()
if (ch = "\n") NumberOfLines++;
Shouldn't this be:
if(ch == '\n')
NumberOfLines++;
Have you tried 'fgetc', instead of 'getc'?
How can you pour one 'unit' - whatever that means - from the coke bottle to the pepsi bottle, when both bottles start full to begin with :confused:
Well, finally got around to trying to correct the problems with this program and I think I've got it working roughly the way that I wanted it to. I've tried to keep things as simple as possible in...
If you declare the variable outside of the 'for' loop - which I assume you have done - then the altered value from the loop will be carried over to the next function/operation in your program, so you...
hk_mp5kpdw: :cool: wow thanks. I see what your saying. It'll give me more feedback on what's occurring, or not occurring, in the program - assuming I implement it correctly of course. :) I'm going...
Errrr... ok. You got me there, I don't know how to do that. Is there any info on this I can read. Cheers.
I'm not sure that you'd really need to have multiple files for a program of this size - unless of course the object of the lesson was to get you writing your own header files. Are you sure that your...
cwr: does '[^\n]' mean, ignore newline character?
dwks: Thanks, I'll give that a go too. :)
Thanks for the response guys.
itsme86: yeah, I think I see what you're saying there. I'm basically trying to cram a very large peg into a very small hole, so to speak. I'm still not 100% clear on...
Hi. I'm noob to this programming business and as part of a self-inflicted learning exercise, I've been trying to write a programme that functions as follows:
- read a string (single word) from...