Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define N 3
- typedef struct Fila {
- char nombre[50];
- int tipo;
- } Fila;
- Fila Filas[N];
- void crearTablaSimbolos(){
- int i;
- for( i = 0; i < N; i++ ){
- strcpy(Filas[i].nombre,"-" );
- Filas[i].tipo = NULL;
- }
- }
- int filaLibre(){
- int i,comprueba;
- for( i = 0; i < N; i++ ){
- comprueba=strcmp(Filas[i].nombre,"-");
- if(comprueba == 0 )
- return i;
- }
- return -1;
- }
- int newTemp(char *nombre ){
- int i = filaLibre();
- if ( i != -1 )
- strcpy(Filas[i].nombre,nombre);
- return i;
- }
- int main(){
- crearTablaSimbolos();
- newTemp(&"Var1");
- printf("%s",Filas[0].nombre );
- printf("\n");
- newTemp(&"Var2");
- printf("%s",Filas[1].nombre );
- printf("\n");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement