I'm making a phonebook and I was trying to implement a system for not letting have repeated names on it.
After a long time trying to debug it, I found the reason why it wasnt working.
...
Type: Posts; User: eidgeare
I'm making a phonebook and I was trying to implement a system for not letting have repeated names on it.
After a long time trying to debug it, I found the reason why it wasnt working.
...
Well, first of all:
Welcome.
As for the compiler, if you're using windows than I'd probably recommend an IDE (C-Dev++) as it is simple to use and easy to get to know it.
On linux either use...
Actually I did try, but using "". My bad.
Sorry for making you lose your time and thank you,
Hugo Ribeira
I've tryed to google it, but did manage to find it.
I'm trying to read 3 diferent variables from a file that looks like this:
Name1
1231321321
12/12/2009
Name2
1232132132
So the file wasnt empty earlier then.
fflush was what made it work, although it should have worked before, because the file was already written to disk.
what about the FILE *pointer? does it...
Thanks, I'll do my homework now on the buffer. :)
Btw Pointers, if I understand them correctly, they store the path to the place where a variable is. Being it in memory or in the harddrive is it...
It works now. Thank you.
Can we just move on to the understanding part, because I wanna try to understand what just went in here.
fflush() and fseek(file_pointer,int x?,SEEK_SET ) do the same...
Allright, here we go:
Opening the file is successfull(please correct the spelling of this word for me, I'm portuguese).
It goes in the IF STATEMENT and printf success.
The output of quzah's...
fseek outputs 0;
after your edit, I flushed the stream by:
fseek(database,0,SEEK_SET)
printf("%d", fseek(database,0,SEEK_END))
but still fseek seek_end outputs 0.
It isnt empty, the program writes variables to it. It's actually a pretty big file now, because everytime I run the app, it writes 3 variables to it [name, bday and cell_number].
database.txt:
...
Yes, I did write it before the last while, also it is skipping the loop because printf("whatever") doesn't print anything.
Added the line but no change.
Is it possible my EOF is in the beggining of the file and that's why it is skipping the loop?
I've oppened the file in "a+" mode, because I want the program to create a new file, if there is no database file. (Imagine I want to take my app to other pc, if there is no database file, then it...
int criar_contacto()
{
char name[33], bday[11];
int cell_phone, cop, x;
char opcao;
FILE *database;
//Input Data Section:
do{
It works now, but I don't understand why.
what goes in that argument is name[], right? which acts as a pointer, so shouldn't I call the argument type a pointer as well?
EDIT: Understood, thank...
int criar_contacto()
{
char name[33], bday[11];
int cell_phone;
printf("Introduza o Nome do contacto:\n");
get_string(name, 33);
printf("%s", name); // This is just for test purpose
Thank you, just realised how stupid I was
First of all, hello everyone.
I'm pretty much a virgin, here and in programming.
So the problem is:
do
{
printf("Introduza o nome do contacto(max. 32 caracteres):\n");