Is there is any function through which i can get specific number of integer like we do through getchar() funtion .I AM USING TURBO C 3.0.HELP WILL BE APPRECIATED.

How about you describe what you're trying to do? What you're asking for is somewhat nonsensical out of context.

You can always get integers using scanf functions.

you can use getw() & putw() functions to get integers from a file opened in binary mode.

Does this answer your question?

And also putw ( n = getw(stdin), stdout ) will seem to work but wont for a good reson. Find it of yourself by analyzing.

Actually the question is that i want to get a int array but dont specify how much i need in programme , like in getchar function can takes 0 to max size of an array , can i do it with int .

Example is this

char arr[100],i=0;

while((arr=getchar())!='\n')
i++;

so it will take any number of character from 0 to max size until enter is not encountered

but in integer i always want a loop any specific number

like

for(i=0;i<3;i++)
scanf("%d",&arr);

but my size of array can get 100 integer more and every time i want to come in main programme to specify how much i need

I think every one got it , so please help.

Why dont you loop it till the user inputs 0 or
till the scanf fails.
i.e., scanf ( "%d", addr ) ;
will scan data as far as it is valid inputs like 'x' when scanf expects integer are invaild & scanf will return 0.

Does this answer your question?

>so it will take any number of character from 0 to max size until enter is not encountered
Well, scanf doesn't recognize a newline, so you'll have to use some other method. A generally good one is to signal EOF when you're done by typing Ctrl+Z (Windows) or Ctrl+D (Unix/Linux), then this works:

int a[100];
int i;

for ( i = 0; i < 100; i++ ) {
  if ( scanf ( "%d", &a[i] ) == 0 )
    break;
}

>so it will take any number of character from 0 to max size until enter is not encountered
Well, scanf doesn't recognize a newline, so you'll have to use some other method. A generally good one is to signal EOF when you're done by typing Ctrl+Z (Windows) or Ctrl+D (Unix/Linux), then this works:

int a[100];
int i;

for ( i = 0; i < 100; i++ ) {
  if ( scanf ( "%d", &a[i] ) == 0 )
    break;
}

hey ,
if you are not looking to use any negative values in your array, I mean if you dont want your array to contain any negative value, then use -1 to termiate taking input for array

This article has been dead for over six months. Start a new discussion instead.