hi,can someone please tell me how i can read in data,save data to a file and print it out to the screen using the "gets" statement.My code starts something like:

#include <stdio.h>;
#include <stdlib.h>;

struct {
	char make[10];
	char model[10];
	double cost;
	int yearMade;
       }cars;

int main ()
{
FILE *myCars;
char cars[200];

myCars = fopen.........
.......................

THANKS :)

So...did you even bother to read any book on C before running here?

>using the "gets" statement
Don't use gets, it's completely unsafe.

well i aint got any c books,if i did i would know what to do:D.what can i use then then as my tutor was recommending the "gets" statement?

>well i aint got any c books
I would have more sympathy for you if the internet weren't a wealth of information. Yet you've bypassed all of the tutorials, references, and ebooks that are available, and gone with the worst possible first step: bothering other people with an easily researched question. Here, let me google that for you since you've already bothered me.

>what can i use then then
fgets. While you're googling, why not look up why gets is unsafe.

>as my tutor was recommending the "gets" statement?
And get a new tutor. Your current one is just clueless enough to ruin your future as a C programmer.

Comments
"let me google that for you"- Cool site :)

will have a good look at that.thought i would get a quick solution on here but thanks for your help anyway.

and my tutor did say i can use gets or fgets so i dont know why he said it

;)

and my tutor did say i can use gets or fgets so i dont know why he said it

May be he is an inclined to sadism person. If so and if you are a latent masochist then use gets...
;)

This article has been dead for over six months. Start a new discussion instead.