Code:
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
return 1;
}
void get_string(char *string_to_get, size_t string_size)
{
int i;
fgets(*string_to_get, string_size, stdin);
for(i=0; i<string_size; i++)
{
if(string_to_get[i]=='\n')
{
string_to_get[i]='\0';
break;
}
}
}
So the first obvious problem here is in "get_string", Eclipse(A linux C SDK) is telling me that "passing argument 1 of ‘fgets’ makes pointer from integer without a cast".
I've got no idea of what it means, I've googled it though, found many things about it but I didn't managed to figure it out by myself.
The code compiles flawlessly, but when I use criar_contacto() which calls get_string() my app just terminates. My main() is just a switch case to create a menu where each case calls a fuction.
My get_string is suposed to get a string with fgets and then cut the "\n" from it, so I don't always have to write the loop to have it done.
I'm trying to make a "notebook for cell phone numbers" (I'm portuguese so I guess that's not what you guys call it, but i hope you get it).
Thanks in advance,
Hugo Ribeira