Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define SIZE 50
- int getint(int *);
- void main(void){
- int i,n,array[SIZE];
- printf("Egeszek tombbe olvasa es visszairasa cimeikkel egyutt!\n");
- printf("Legfeljebb %d egesz szam van vagy EOF-ot megadva kevesebb!\n",SIZE);
- printf("Adja meg az egesz szamokat!\n\n");
- for(n=0;n<SIZE&&getint(&array[n])!=EOF;n++);
- printf("\n\nA tombelemek cimei rendre:\n\n");
- for(i=0;i<n;i++) printf("%10p",&array[i]);
- printf("\n\nA tombelemek ertekei rendre:\n\n");
- for(i=0;i<n;i++) printf("%10d",array[i]);
- getch();
- }
- int getch(void);
- int ungetch(int);
- int getint(int *pn){ /* A következő egész bevolvasása*/
- int c,sign=1;
- //az elől lévő üres karakterek átlépése
- while((c=getch())==' ' || c=='\n' || c=='\t' );
- if(c=='+' || c=='-' ){
- sign=(c=='+')?1:-1;
- c=getch();
- }
- // A szám behozatala és konverziója
- for(*pn=0;c>='0' && c<'9';c=getch()){
- *pn=10**pn+c-'0';
- }
- *pn*=sign;
- if(c!=EOF) ungetch(c);
- return c;
- }
- #define BUFSIZE 100
- char buf[BUFSIZE];
- int bufp=0;
- int getch(void){
- return((bufp>0)?buf[--bufp]:getchar());
- }
- int ungetch(int c)
- {
- if(bufp>=BUFSIZE){
- printf("\n\tUngetch: Tul sok karakter!\n");
- return EOF;
- }else{
- return buf[bufp++]=c;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement