I'm trying to take from stdin in a format like this
3
0 -1 1 -1 2
2 0 -1 -1 -1
2 -1 -1 0 -1
4
1 0
1 2
2 2
0 1
and create structs and fill in the states based on that information
Whenever I enter in these inputs it seems to stop whenever it sees a 0 or a 2
I have no idea whats causing this
Here is my code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void getInput();
int getNrOfX();
int getCurrentRoom();
struct Room {
int state;
int northState;
int southState;
int eastState;
int westState;
};
struct Creature {
int type;
int location;
};
int main() {
//creates all the inital rooms and creatures
int nrOfRooms = getNrOfX();
struct Room rooms[nrOfRooms];
for(int i = 0; i < nrOfRooms; i++){ //creates rooms and stores them into the rooms array
scanf("%d %d %d %d %d", rooms[i].state, rooms[i].northState, rooms[i].southState, rooms[i].eastState, rooms[i].westState);
}
int nrOfCreatures = getNrOfX();
struct Creature creatures[nrOfCreatures];
for(int i = 0; i < nrOfCreatures; i++){ //creates creatures and stores them in the creatures array
scanf("%d %d", creatures[i].type, creatures[i].location);
}
//Gameplay loop
while (1) {
char input[30];
scanf("%s", input);
if(strcmp(strupr(input), "LOOK") == 0) {
int playerLocation = getCurrentRoom(nrOfRooms, &creatures);
printf("Room State %d\n", rooms[playerLocation].state);
printf("%d\n", rooms[playerLocation].northState);
break;
}
}
return 0;
}
int getNrOfX() {
int nrOfX;
scanf("%d", &nrOfX);
return nrOfX;
}
int getCurrentRoom(int nrOfRooms, struct Creature *creature) {
for(int i = 0; i < nrOfRooms; i++) {
if (creature[i].type == 0){
return creature[i].location;
}
}
}
The program compiles but when I enter the input
2 0 -1 -1 -1
ParserError:
Line |
1 | 2 0 -1 -1 -1
| ~
| Unexpected token '0' in expression or statement.
Please let me know what I can do
I have no idea whats causing this
Save time, enable all warnings
Enable the compiler to fully do its job.
format '%d' expects argument of type 'int *', but argument 6 has type 'int' [-Wformat=]
scanf("%d %d %d %d %d", rooms[i].state, rooms[i].northState, rooms[i].southState, rooms[i].eastState, rooms[i].westState);
With scanf(), "%d" matches an int *, not an int.
// scanf("%d %d %d %d %d", rooms[i].state, rooms[i].northState, rooms[i].southState, rooms[i].eastState, rooms[i].westState);
scanf("%d %d %d %d %d", &rooms[i].state, &rooms[i].northState,
&rooms[i].southState, &rooms[i].eastState, &rooms[i].westState);
Same for scanf("%d %d", creatures[i].type, creatures[i].location);.
In function 'getCurrentRoom':
:1: warning: control reaches end of non-void function [-Wreturn-type]
getCurrentRoom() does not always return a value.
Related
Hello everyone I have a program that picks up some factors from the user
For the purpose of planning workers in the factory
1 ID
2 working hours
3 Wages
4 How many workers there are in the factory
The program ran and everything is fine but the program fails to print the requested values
For example for the value 2 employees, ID 23, 34
Wage hours etc. The program prints an ugly and large number and for the ID printed 2! And not 23 34
How do I fix the ID and everything?
I mention again the output looks like this!
**
**number of Factory workers
2
ID: 2
Hour lySal: -858993460
workdays: -858993460
salary: -858993460
worker day is: 2 worker hours is: -858993460
ID: 2
Hour lySal: -858993460
workdays: -858993460
salary: -858993460
worker day is: 2 worker hours is: -858993460
C:\Users\יובל\source\repos\lastpartproject\Debug\lastpartproject.exe (process 8488) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .**
**
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int DayNumber; //1-31
int WorkHours; // 1-12
} WorkDay;
typedef struct {
long ID;//ת.ז.
int HourlySal; // שכר לשעה
int workdays; //מספר ימי עבודה של העובד בחודש הנוכחי
WorkDay* wd; // מצביע למערך דינאמי של נתוני ימי העבודה בחודש נוכחי
double salary; // סה"כ שכר עבודה של העובד בחודש נוכחי
} Worker;
Worker* InitFactory(int* pSize);
void PrintFactory(Worker* pWorker, int size);
void CalculateSalary(Worker* pWorker, int size);
void InputWorkDay(WorkDay* pWD);
void PrintWorkDay(WorkDay wd);
void InputWorker(Worker* pW);
void PrintWorker(Worker w);
int main() {
Worker* pFactory = NULL;
int size = 0;
pFactory = InitFactory(&size);
CalculateSalary(pFactory, size);
PrintFactory(pFactory, size);
// free memory -
}
void InputWorkDay(WorkDay* pWD)
{
printf("input worker day and worker hours\n");
scanf("%d %d", &(pWD->DayNumber), &(pWD->WorkHours));
}
void PrintWorkDay(WorkDay wd)
{
printf("worker day is: %d worker hours is: %d\n", wd.DayNumber, wd.WorkHours);
}
void InputWorker(Worker* pW)
{
printf("input ID\n");
scanf("%d", &(pW->ID));
printf("Hour lySal\n");
scanf("%d", &(pW->HourlySal));
printf("input workdays\n");
scanf("%d", &(pW->workdays));
printf("input salary\n");
scanf("%d", &(pW->salary));
InputWorkDay(pW->wd);
}
void PrintWorker(Worker w)
{
printf("ID: %d\n", w.ID);
printf("Hour lySal: %d\n", w.HourlySal);
printf("workdays: %d\n", w.workdays);
printf("salary: %d\n", w.salary);
PrintWorkDay(w.wd[0]);
}
Worker* InitFactory(int* pSize)
{
int number_student = 0;
Worker* Pfactory = NULL;
printf("number of Factory workers\n");
scanf("%d", &number_student);
*pSize = number_student;
Pfactory = (Worker*)malloc(*pSize * sizeof(Worker));
if (Pfactory == NULL)
{
printf("no storage\n");
exit(1);
}
for (int i = 0; i < *pSize; i++)
{
Pfactory[i].wd = (WorkDay*)malloc(31 * sizeof(WorkDay));
InputWorker(&Pfactory[i]);
}
}
void PrintFactory(Worker* pWorker, int size)
{
for (int i = 0; i < size; i++)
{
PrintWorker(*pWorker);
}
}
void CalculateSalary(Worker* pWorker, int size)
{
for (int j = 0; j < size; ++j)
{
//pWorker[j].HourlySal* pWorker[j].workdays;
}
}
At least these problem:
Assignment fails as InitFactory() does not return a value.
pFactory = InitFactory(&size);
Found this quickly by having many warnings enabled:
warning: control reaches end of non-void function [-Wreturn-type]
Save time, be more productive. Enable all warnings.
Other samples:
scanf("%d", &(pW->salary));
warning: format '%d' expects argument of type 'int', but argument 2 has type 'long int' [-Wformat=]
printf("salary: %d\n", w.salary);
warning: format '%d' expects argument of type 'int', but argument 2 has type 'double' [-Wformat=]
There are more like errors to find.
I am attempting to make a simple dice program. The program can run 2 ways: Either by using scanf() to get the amount of dice needed to be rolled, or by passing the amount of dice to be rolled as an argument.
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#if !defined(CLOCK_MONOTONIC)
#error CLOCK_MONOTONIC is not defined
#endif
int main(int argc, char *argv[]) {
if (argc > 2){
printf("\nExpected exactly one argument, received %d\n", argc);
return 1;
} else if (argc == 1){
void Randomize() {
struct timespec tmp;
clock_gettime(CLOCK_MONOTONIC,&tmp);
srand(tmp.tv_nsec);
}
int Random(int Max) {
return ( rand() % Max)+ 1;
}
int amount;
printf("Enter the amount of dice to roll: ");
scanf( "%d", &amount );
printf("\nYou entered: %d ", amount);
printf("\n");
Randomize();
int i;
int totals[6];
for (i=1;i<=6;i++)
totals[ i ]=0;
for (i=0;i<amount;i++) {
int d=Random(6) ;
int total=d;
totals[ total ]++;
}
for (i=1;i<=6;i++) {
printf("%i %i\n\r",i,totals[ i ]) ;
}
} else {
int amount = *argv[1];
printf("Getting dice: %d\n", amount);
void Randomize() {
struct timespec tmp;
clock_gettime(CLOCK_MONOTONIC,&tmp);
srand(tmp.tv_nsec);
}
int Random(int Max) {
return ( rand() % Max)+ 1;
}
Randomize();
int i;
int totals[6];
for (i=1;i<=6;i++)
totals[ i ]=0;
for (i=0;i<amount;i++) {
int d=Random(6) ;
int total=d;
totals[ total ]++;
}
for (i=1;i<=6;i++) {
printf("%i %i\n\r",i,totals[ i ]) ;
}
}
return 0;
}
The first and second portions of the code works as intended. That is, if parsing more than one argument (in addition to the program name itself) the program will exit with intended message.
If not parsing an argument (in addition to the program name itself) the program also works as intended.
The issue is with the third portion of code, wherein I should be able to use ./a.out 123 to get 123 random dice.
When I try this method, I receive:
Getting dice: 49
1 8
2 10
3 6
4 7
5 7
6 11
as the output, regardless of what argument I pass.
Why is 49 always the amount specified, regardless of the argument passed, and how can I modify the program to get the correct integer as an argument?
Edit: Formatting x2
I wrote a program in C which takes as an input a value and an ordered Array of integers and performs a ternary search to find the value(if it exists) inside the Array.
I have seen all the possible problems with the usage of scanf and the related topics here in Stackoverflow.
I have noticed that there is a difference if I call the 2 scanf functions in reverse order.
If I use the code as it is below. First read the value and after the array from the user, the program and scanf functions as expected.
printf("Enter the value to be searched in the Array: ");
int k;
scanf(" %d", &k);
printf("Type elements of A(sorted) separated by spaces (type 'end' to stop): ");
i = 0;
while(scanf("%d", &A[i]) == 1) {
i++;
}//while
Although if I use the scanf inputs in the reverse order the second scanf never stops to get user input and read values left in the buffer.
printf("Type elements of A(sorted) separated by spaces (type 'end' to stop): ");
i = 0;
while(scanf("%d", &A[i]) == 1) {
i++;
}//while
printf("Enter the value to be searched in the Array: ");
int k;
scanf(" %d", &k);
I cannot understand what is the difference in the calling order.
I have tried the solutions mentioned in the other threads but none worked.
Just as a reference here is the whole code(working as expected):
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int ternarySearch(int A[], int l, int r, int k){
int i;
int first,second;
if(l>r){
return -1;
}
i= (r - l)/3;
if(i==0){
i++;
}
first = i+l-1;
second = i*2+l-1;
if(A[first]==k){
return first;
}
else if(A[first]>k){
ternarySearch(A, l, first-1, k);
}
else
{
if(A[second]==k)
return second;
else
if(A[second]>k)
ternarySearch(A, first+1,second-1, k);
else
ternarySearch(A, second+1,r, k);
}
}
int main(){
const int maxarraylen = 1000;
int i;
int n;
int A[maxarraylen];
char string[250];
printf("Enter the value to be searched in the Array: ");
int k;
scanf(" %d", &k);
printf("Type elements of A(sorted) separated by spaces (type 'end' to stop): ");
i = 0;
while(scanf("%d", &A[i]) == 1) {
i++;
}//while
n=i-1;
//We assume the array is sorted otherwise we can use any sorting algorithm e.g. code from task1
scanf(" %d", &k);
int result;
result=ternarySearch(A, 0, n, k);
if(result==-1){
printf("The value was not found in the Array.\n");
}
else{
printf("The value was found in position no. %d.\n", result);
}
return 0;
}
Your problem is that you are not 'stepping over' your end input.
We can see this by doing an experiment using the following program:
#include <stdio.h>
#include <stdlib.h>
void main(void) {
FILE *f;
long f_pos;
int ret;
int i;
int data[5];
int data_last;
int search;
f = fopen("./input.txt", "r");
if (f == NULL) {
perror("fopen()");
return;
}
/* read in the values for the array */
data_last = -1;
for (i = 0; i < 5; i++) {
ret = fscanf(f, "%d", &(data[i]));
printf("fscanf(data[%d]): ret: %d\n", i, ret);
f_pos = ftell(f);
printf("ftell(): %ld\n", f_pos);
if (ret != 1) {
break;
}
data_last = i;
}
/* check that we read in at least one value */
if (data_last == -1) {
printf("no input data!\n");
return;
}
/* insert 'fix' here */
/* pre-load the 'search' with known garbage */
search = 987;
/* now read in the search value */
ret = fscanf(f, "%d", &search);
printf("fscanf(search): ret: %d\n", ret);
f_pos = ftell(f);
printf("ftell(): %ld\n", f_pos);
/* print out our info */
for (i = 0; i <= data_last; i++) {
printf("data[%d]: %d\n", i, data[i]);
}
printf("search for: %d\n", search);
return;
}
With the following data in input.txt:
123
456
end
456
The output is as follows:
fscanf(data[0]): ret: 1
ftell(): 3
fscanf(data[1]): ret: 1
ftell(): 7
fscanf(data[2]): ret: 0
ftell(): 8
fscanf(search): ret: 0
ftell(): 8
data[0]: 123
data[1]: 456
search for: 987
ftell() tells us where the file's cursor is, and in this case we can see that it is at byte 8... the e of the input line end.
It doesn't get past it, and thus the next attempt to read a number (%d) will fail too!
It's also a good idea to check the return values! We can see that the fscanf(&search) call has failed to read a number!
The solution is to insert this snippet just after we check that we recieved array values:
/* this is the 'fix' */
ret = fscanf(f, "end");
printf("fscanf(end): ret: %d\n", ret);
f_pos = ftell(f);
printf("ftell(): %ld\n", f_pos);
This is an activity given by my instructor.
Create a program that accepts numeric input from the user. If the user enters an even number, store it to an array for even numbers. If the user enters an odd number, store it to another array for odd numbers. Input terminates if the user entered 10 numbers already. Display the size of each array and their elements.
Example:
Input: 5, 6, 12, 10, 0, 3, 4, 100, -1, 7
Even numbers (6): 6 12 10 0 4 100
Odd numbers (4): 5 3 -1 7
and this is the code I've come up with.
#include <stdio.h>
int sort(int);
int main(){
int input, count;
for(count=0;count!=10;count++){
printf("Enter 10 digits: ");
scanf("%d", &input);
sort(input);
}
printf("%d", input);
return 0;
}
int sort(int inp){
int odd[10];
int even[10];
if(inp%2==0){
odd[]=inp;
}
else
even[]=inp;
return 0;
}
Please help me on how to store the numbers into two separate arrays. Any tips will be greatly appreciated.
Check the below code. It's self-explaining.
#include <stdio.h>
#include <stdlib.h>
#define NUM 10
int main()
{
int input, i;
int oddcounter = 0, evencounter =0;
int oddarr[NUM];
int evenarr[NUM];
printf("Enter 10 integers\n");
for (i = 0; i < NUM; i++)
{
if ( scanf("%d", &input) == 1 )
{
if ((input % 2) == 0)
{
evenarr[evencounter++] = input;
}
else
{
oddarr[oddcounter++] = input;
}
}
}
printf("Number of elem in oddarray : %d, evenarray : %d\n\n", oddcounter, evencounter);
printf("Odd elements are :");
for (i = 0; i < oddcounter ; i++) printf("%d\t", oddarr[i]);
printf("\n");
printf("Even elements are :");
for (i = 0; i < evencounter; i++) printf("%d\t", evenarr[i]);
printf("\n");
return 0;
}
In addition to Sourav's comment which indicates that you shouldn't have the int[] arrays be local to sort, this syntax isn't correct for assigning to arrays in C:
odd[]=inp;
On my compiler, it generates the following error:
24:9: error: expected expression
odd[]=inp;
To store to odd, you need to indicate the index at which you'd like to store, for example:
odd[1]=inp;
which also means you'll need to keep track the latest index you wrote to for each array!
You need to tell the compiler which index of the array you are storing your data to. In sort:
if(inp%2==0){
odd[]=inp;
}
else
even[]=inp;
return 0;
}
Should look something like:
if(inp%2==0){
odd[endofoddindex]=inp;
}
else
even[endofevenindex]=inp;
return 0;
}
That said, you won't get much use out of the arrays being local variables, since they are deallocated on each call. Your best bet is to declare the arrays in main and pass them in.
Your even and odd arrays are both local. This means that they exist as long as the function exists. So you won't be retrieve the data you have stored(You also don't store it correctly).
So you need both the arrays in main and also two other variables for using as the index of both the array(i and j in the below program). The modified program is given below:
#include <stdio.h>
int sort(int);
int main(){
int input, count,i=0,j=0; //i and j to be used as array indices
int odd[10];
int even[10]; //arrays in main
for(count=0;count!=10;count++){
printf("Enter 10 digits: ");
scanf("%d", &input);
if(sort(input)) //if odd number was found
odd[i++]=input;
else //even number found
even[j++]=input;
}
printf("%d", input);
//print even and odd arrays here
return 0;
}
int sort(int inp){
if(inp%2==0)
return 0; //if number is even,return 0
return 1; //else return 1
}
You need to either have your arrays as globals or pass them into your sort function. Where they are they currently they get recreated every time the sort function is called and are inaccessible to the rest of your program.
You will also need to keep track of the max number of ints in each array and the current number.
Your test in sort would be something like this:
if( inp % 2 == 0)
{
//TODO check that currentEvenCount < maxEvenCount
even[ currentEvenCount ] = inp;
currentEvenCount++
}
else
{
//TODO check that currentOddCount < maxOddCount
odd[ currentOddCount ] = inp;
currentOddCount++;
}
To declare your arrays as globals just move the declaration outside of any function above anywhere they are referenced
int even[10];
int odd[10];
int main() ...
To pass them as parameters to sort function you could declare sort like this:
sort( int inp, int even[], int maxEvenCount, int* currentEvenCount, int odd[]. int maxOddCount, int* currentOddCount)
{
...
if( inp % 2 == 0)
{
//TODO check that currentEvenCount < maxEvenCount
even[ *currentEvenCount ] = inp;
(*currentEvenCount)++
}
}
The * in front of currentEventCount is dereferencing the pointer and getting/setting the actual value pointed to.
You would then call sort like so:
int main()
{
int evenArray[10];
int oddArray[10];
int currentEvenCount = 0;
int currentOddCount = 0;
...
sort( input, evenArray, 10, ¤tEvenCount, oddArray, 10, ¤tOddCount);
}
There is no any sense to define the arrays as local variables of function sort because each time the function is called the arrays are created anew.
The program could look the following way
#include <stdio.h>
#define N 10
enum Type { Even, Odd };
enum Type sort( int x )
{
return x % 2 == 0 ? Even : Odd;
}
int main( void )
{
int odd[N];
int even[N];
int odd_count = 0;
int even_count = 0;
int i;
printf( "Enter %d numbers: ", N );
for( i = 0; i < N; i++ )
{
int num;
scanf( "%d", &num );
switch ( sort( num ) )
{
case Even:
even[even_count++] = num;
break;
case Odd:
odd[odd_count++] = num;
break;
}
}
printf( "Even numbers (%d):", even_count );
for ( i = 0; i < even_count; i++ ) printf( " %d", even[i] );
printf( "\n" );
printf( "Odd numbers (%d):", odd_count );
for ( i = 0; i < odd_count; i++ ) printf( " %d", odd[i] );
printf( "\n" );
return 0;
}
If to enter
5 6 12 10 0 3 4 100 -1 7
then the output will be
Even numbers (6): 6 12 10 0 4 100
Odd numbers (4): 5 3 -1 7
Simply copy, paste and investigate the program.:)
Hope this program will solve you issue. Here is the working code.
#include <stdio.h>
int sort(int[]);
int main(){
int input[10], count;
printf("Enter 10 digits: ");
for(count=0;count<10;count++){
scanf("%d", &input[count]);
}
sort(input);
return 0;
}
int sort(int inp[]){
int odd[10];
int even[10];
int oddCount=0, evenCount=0;
int i;
for(i=0; i<10;i++)
{
if(inp[i]%2==0){
even[evenCount]=inp[i];
evenCount++;
}
else
{
odd[oddCount]=inp[i];
oddCount++;
}
}
printf("ODD COUNT is %d \n", oddCount);
for(i=0; i<oddCount;i++)
{
printf("ODD VALUE %d \n", odd[i]);
}
printf("EVEN COUNT is %d \n", evenCount);
for(i=0; i<evenCount;i++)
{
printf("EVEN VALUE %d \n", even[i]);
}
return 0;
}
Your variable input is just an int, it's not an array. You need two arrays:
int even[10], odd[10];
Then you need to keep track of the number of numbers you've read so far, and for each number check which array to store it in.
I don't see a need to do sorting, so not sure why you have a function called sort().
It should just be something like:
int even[10], odd[10];
int oddindex = 0, evenindex = 0;
while(scanf(" %d", &x) == 1)
{
if(x % 2 == 0)
even[evenindex++] = x;
else
odd[oddindex++] = x;
if((evenindex + oddindex) >= 10)
break;
}
/* Loop here to print numbers. */
An answer suitable for an assignment question:
int main()
{
int i,c,o[10],e[10];int oc=0;int ec=0;int*pc;for(c=0;c<10;c++){scanf("%d",&i);pc=(i&1)?&o[oc++]:&e[ec++];*pc=i;}
// Now print out the values as requested in oc, o, ec and e.
}
I'm wondering on how to basically input exactly 5 numbers (integers specifically) in one line using simple commands such as while, if and arrays. For example:
if I input 5 numbers separated by spaces,
1 2 3 4 5
program would print
1 2 3 4 5
but, If I input less than 5 or more than 5,
1 2 3 4
program would print
invalid input.
So far I have
#include<stdio.h>
int main(int argc,char *argv[]){
int array[5], numbers;
numbers = 0;
while (numbers < 5) {
scanf("%d", &array[numbers]);
numbers = numbers + 1
}
printf("%d %d %d %d %d\n", array[0], array[1], array[2], array[3], array[4]);
return 0;
}
What about if we assign all the array cell with 9999 (a number not used by the program). And we make a loop to check that each array has been changed to a new value and if its still 9999 it would be invalid. But problem here still lies, how would we just grab one line of different number of input and move on. E.g input 2 3
Output 2 3 9999 9999 9999
Or input 2 3 4
Output 2 3 4 9999 9999
If you want to force the input to be on one line, first read the input and then parse it:
char line[100];
fgets(line, 100, stdin);
char x[100];
int n = sscanf(line, "%d %d %d %d %d %s", array, array+1, array+2, array+3, array+4, x)
if (n != 5)
printf("invalid input\n");
else
printf("read 5 numbers\n");
The x is added to detect if too much was read.
EDIT
To enter 5 numbers you may use
int a[5];
char x;
scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);
while(scanf("%*[^\n]%*c")) {
scanf("%c", &x); // after 5 ints were loaded, get rid of rest of the elements untill new line symbol
}
printf("%d %d %d %d %d\n\n", a[0], a[1], a[2], a[3], a[4]);
It will ignore everything after 5 numbers (in fact, it will write to x untill new line symbol appears), but there is no way to easily set number of numbers to read in this case.
You just have to note it will not work if you have less than 5 ints in line.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int intRead(int array[], int size){
char buff[128];
int status=!0;//status == 0, Something happened!
printf("\ninput %d integer:", size);
while(fgets(buff, sizeof(buff), stdin)){
int count=0;
char*p;
for(p=buff;NULL!=(p=strtok(p, " \t\n"));p=NULL){
char *ck;
int i;
i=(int)strtol(p, &ck, 0);
if(*ck){
fprintf(stderr, "invalid input:can't parse of int <<%s>>\n", p);
status=0;
continue;
}
if(count < size){
array[count++]=i;
continue;
}
count = size + 1;//more than
break;
}
if(count < size)
fprintf(stderr, "invalid input: less than %d\n", size);
else if(count == size) return status;
if(count > size)
fprintf(stderr, "invalid input: more than %d\n", size);
printf("\ninput %d integer:", size);
status = !0;
}
return 0;
}
int main(int argc,char *argv[]){
int array[5];
intRead(array, 5);//or: while(!intRead(array, 5));
printf("%d %d %d %d %d\n", array[0], array[1], array[2], array[3], array[4]);
return 0;
}