🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #8969

Problemas con fgets

#8969
From: quantium
Date: Sun, 22 Sep 2002 00:29
30 lines
1662 bytes
Hola.
Tengo un problema con fgets, os comento lo que hace el programa, lo 
primero que haces es pedir una opcion, si la opcion es 'a' despues 
deberia insertar una frase usando fgets, pero esto no ocurre, he leido 
algo sobre que scanf pone un '\n' a las variables. �alguien sabe como 
soluccionar el problema? Muchas gracias.

#include <stdio.h>

int main()
{
	char empezar,opcion,phrase[50];
	
	do{
		printf("inserta una opcion: ");
		scanf("%c",&opcion);
		switch(opcion){
			
			case 'a':
			printf("inserta una frase:");
			fgets(phrase,sizeof(phrase),stdin);
			printf("la frase es: %s",phrase);
			break;
			
		}
	
	printf("�empezar (s/n)?: ");
	scanf(" %c",&empezar);
	}while(empezar=='s');
}
Technical Details
Message-ID: <3D8D0ED3.6010209@lycos.es>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!193.174.75.178!news-fra1.dfn.de!fu-berlin.de!uni-berlin.de!67-madr-x25.libre.retevision.ES!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,168f0a0156c19b86,start
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-09-21 17:29:08 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!193.174.75.178!news-fra1.dfn.de!fu-berlin.de!uni-berlin.de!67-madr-x25.libre.retevision.ES!not-for-mail
From: quantium <quantium@lycos.es>
Newsgroups: es.comp.os.linux.programacion
Subject: Problemas con fgets
Date: Sun, 22 Sep 2002 02:29:07 +0200
Lines: 31
Message-ID: <3D8D0ED3.6010209@lycos.es>
NNTP-Posting-Host: 67-madr-x25.libre.retevision.es (62.83.12.67)
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fu-berlin.de 1032654547 6687648 62.83.12.67 (16 [129971])
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0rc3) Gecko/20020523
X-Accept-Language: en-us, en