Advertisement
LuandaBernardo

Alocação Dinâmica

Dec 11th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<conio.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6.  
  7. void preenche (int *n, char **nome)
  8. {
  9.     int i, n;
  10.      printf ("\n Digite o numero de pessoas:");
  11.     scanf ("%d", &n);
  12.     V = (float*) malloc (n * sizeof(float));
  13.     nome = (char**) malloc (n * sizeof (char*));
  14.     for (i=0; i<n; i++)
  15.     { nome[i] = (char*) malloc (30* sizeof (char));}
  16.    
  17.     for (i=0; i<n; i++)
  18.     {
  19.         printf ("[%d] = ", i);
  20.         scanf ("%d", &V[i]);}
  21.        
  22.         for (i=0; i<n; i++)
  23.        
  24.         {
  25.             fflush (stdin);
  26.              gets ( nome[i]);}
  27. }
  28.  
  29.  
  30.  
  31.  
  32.  
  33. main ()
  34. {
  35.     int opcao, n, i, j;
  36.     float *V;
  37.     char  **nome;
  38.     printf (" 1 - Cadastrar notas \n 2 - Exibir Media Geral \n 3 - Exibir Resultado Geral  \n 4 - Exibir resultado individual \n 5 - Sair");
  39.     scanf ("%d", &opcao);
  40.    
  41. switch (opcao)
  42. case 1:
  43.    
  44. break;
  45.    
  46.                     case 5:
  47.                          return 0;
  48.                          break;    
  49.    
  50.    
  51.    
  52.    
  53.    
  54.     getch ();
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement