Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define N 3
  6.  
  7. typedef struct Fila {
  8. char nombre[50];
  9. int tipo;
  10. } Fila;
  11.  
  12. Fila Filas[N];
  13.  
  14.  
  15.  
  16. void crearTablaSimbolos(){
  17.  
  18. int i;
  19.  
  20. for( i = 0; i < N; i++ ){
  21. strcpy(Filas[i].nombre,"-" );
  22. Filas[i].tipo = NULL;
  23. }
  24.  
  25.  
  26.  
  27. }
  28.  
  29. int filaLibre(){
  30. int i,comprueba;
  31. for( i = 0; i < N; i++ ){
  32. comprueba=strcmp(Filas[i].nombre,"-");
  33. if(comprueba == 0 )
  34. return i;
  35. }
  36.  
  37. return -1;
  38.  
  39. }
  40.  
  41. int newTemp(char *nombre ){
  42.  
  43. int i = filaLibre();
  44. if ( i != -1 )
  45. strcpy(Filas[i].nombre,nombre);
  46.  
  47. return i;
  48.  
  49. }
  50.  
  51. int main(){
  52.  
  53. crearTablaSimbolos();
  54.  
  55. newTemp(&"Var1");
  56.  
  57. printf("%s",Filas[0].nombre );
  58. printf("\n");
  59.  
  60. newTemp(&"Var2");
  61.  
  62. printf("%s",Filas[1].nombre );
  63.  
  64. printf("\n");
  65. system("pause");
  66.  
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement