Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/03/2014, 20:42
olivitin
 
Fecha de Ingreso: marzo-2014
Mensajes: 1
Antigüedad: 10 años, 2 meses
Puntos: 0
Error en Programa

Hola! quisiera saber porque este codigo truena cuando ingreso el nombre del archivo.
Gracias por su ayuda


#include <iostream.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
void cortar(char linea [50])
{
char lin[50];
strcpy(lin,linea);
char *token=strtok(lin," ");
if(strcmp(token,"mkdir")==0)
{
cout<<"Se creo directorio" <<endl;
}
if(strcmp(token,"mkfile")==0)
{
cout<<"se creo archivo"<<endl;
}
if(strcmp(token,"type")==0)
{
cout<<"Se mostro"<<endl;
}
if(strcmp(token,"dir")==0)
{
cout<<"Directorio"<<endl;
}
if(strcmp(token,"cd")==0)
{
cout<<"open"<<endl;
}
if(strcmp(token,"cd..")==0)
{
cout<<"Regresar"<<endl;
}
}

void main()
{
FILE *f;
char nomb[20];
char linea[100];
cout<<"Ingrese nombre del archivo\n";
gets(nomb);
f=fopen(nomb,"w+");
if(f==NULL)
{
cout<<"No se puede abrir el archivo\n";
}
while(!feof(f))
{
fgets(linea,50,f);
cortar(linea);
}
fclose(f);
getch();
}