home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 19016 < prev    next >
Encoding:
Text File  |  1992-12-30  |  1.0 KB  |  35 lines

  1. Path: sparky!uunet!spool.mu.edu!olivea!apple!netcomsv!mama!netcomsv!ulogic!hartman
  2. From: hartman@ulogic.UUCP (Richard M. Hartman)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Arrays with variable dimensions?
  5. Message-ID: <788@ulogic.UUCP>
  6. Date: 30 Dec 92 01:28:06 GMT
  7. References: <1992Dec26.220736.22177@news.ysu.edu>
  8. Organization: negligable
  9. Lines: 24
  10.  
  11. You got more details than "vary according to user input"?
  12.  
  13. Off the top of my head (w/ no safety checks & uncompiled)
  14. a program that creates and fills an array where each value
  15. in the array is 2 times the index value (no output of course,
  16. but who's counting?):
  17.  
  18. main()
  19. {
  20.     int sz, i;
  21.     int *a;
  22.     printf("Enter array size:\n");
  23.     sscanf("%d", &sz);
  24.     a = (int *) malloc(sz * sizeof(int));
  25.     for (i=0; i<sz; i++)
  26.         a[i] = i*2;
  27. }
  28.  
  29.  
  30. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  31. Blasting, bursting, billowing forth with    |
  32. the power of ten billion butterfly sneezes,    |    -Richard Hartman    
  33. Man, with his flaming fire,            |    hartman@uLogic.COM
  34. has conquered the wayword breezes.        |
  35.