Basicaly I'm trying to do this

int create_student(student_data *student){
	printf("Nome do aluno:\n");
	fgets(student->name,name_limit,stdin); //wtf?
	
	printf("NĂºmero do aluno\n");
	fgets(student->number,name_limit,stdin);
	
	printf("Aqui devia estar um nome %s",student->name);
	
	
	return 1;
}

Where student is a custom struct, student->name is char array. For some reason it seems to skip the fgets. Replacing with gets has no effect but scanf does seem to work.

If you think the problem lies with something else in my code I can post it. I just don't want to scare people away :P

Edit: Recently replaced number with a char array and the second fgets does seem to work. Just not the first one.

This was part of a triple post

Dammit, i hate it when this happens

I don't see how that would help.

Dont take any input using scanf or gets , anywhere in the program.

I'm not using it anywhere.

The 'skipping' is likely an effect of taking input elsewhere and leaving a newline in the stdin. So I would tend to think your issue is in other code.

Wouldn't fflush(stdin) solve it though? Is there a way I can clear it if that doesn't work?

If you take all input as a string using fgets, you can pretty much eliminate the "need" to fflush(stdin). (Which is what I'd said in the tutorial -- although I think some parts were trimmed from it.)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.