http://www.eecs.harvard.edu/~ellard/Q-97/HTML/root/node55.html#mem2cC
#include <stdlib.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
//#include <conio.h>
int mygetch(){
struct termios oldt,
newt;
int ch;
tcgetattr( STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
ch = getchar();
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
return ch;
}
int main(){
int* array;
int n,i;
printf("Enter the number of elements: ");
scanf("%d",&n);
array = (int*) malloc (n*sizeof(int));
for (i=0; i<n ;i++){
printf("Enter number %d: ", i);
scanf("%d", &array[i]);
}
printf("\nThe Dynamic Array is: \n");
for (i=0; i<n; i++){
printf("The value of %d is %d\n", i, array[i]);
}
printf("Size = %d\n", i);
// mygetch();
free(array);
return 0;
}
References:
http://www.roseindia.net/c-tutorials/c-dynamic-array.shtml
Substitute getch() with mygetch()
http://cboard.cprogramming.com/faq-board/27714-faq-there-getch-conio-equivalent-linux-unix.html
Termios.h
http://pubs.opengroup.org/onlinepubs/007908799/xsh/termios.h.html
General Terminal Interface:
http://pubs.opengroup.org/onlinepubs/007908799/xbd/termios.html
What is termios?
Terminal Concepts in GNU/Linux:
http://frank.harvard.edu/~coldwell/terminals/
Chip's Homepage:
http://frank.harvard.edu/~coldwell/
Paul Horowitz Seti Group in Harvard
http://seti.harvard.edu/
Linux Device Driver (Chinese Version):
http://oss.org.cn/kernel-book/ldd3/
http://oss.org.cn/html/index.html
No comments:
Post a Comment