In my program my fgets funtion wont read inputs when i execute program...whats wrong

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dcowboyz31
    New Member
    • May 2010
    • 3

    In my program my fgets funtion wont read inputs when i execute program...whats wrong

    /* I didnt copy my functions on here so it wouldnt be as long if those could be the problem ill copy those as well */


    #include <stdio.h>
    #include <math.h>
    #include <stdlib.h>
    #include <string.h>
    #define N 20
    #define M 5
    #define A 10
    int* array( int *arr , int size );
    int median( int* arr );
    void sort( int arr[] , int k );
    int* merge( int* array1 , int* array2 );
    void upper( char* str );

    int main(void){
    char string [80] ;
    int array1[N];
    int j;
    int i;

    int ARRAY1[10];
    int ARRAY2[10];
    int med[M];


    printf(" Hello this program is going to do 6 different funtions \n" );

    printf(" Can you please type up to 20 numbers \n");

    for( j = 0 ; j < N ; j++ ){
    scanf( "%d", &array1[j] );
    }
    array( array1 , N );

    printf( " \n Now can you please type in 5 integers so we can calculate the median of them \n " );

    for( i = 0 ; i < M ; i++ ){
    scanf( "%d" , &med[i] );
    }
    sort( med , M );
    median( med );
    printf( " Can you please type in 10 elements for array 1 from least to greatest\n ");
    for( i = 0 ; i < 10 ; i++ ) {
    scanf( "%d" , &ARRAY1[i] );
    }

    printf( " Can you please type in 10 elements for array 2 from least to greatest\n ");
    for( i = 0 ; i < 10 ; i++ ) {
    scanf( "%d" , &ARRAY2[i] );
    }





    merge( ARRAY1 , ARRAY2 );
    printf( "Enter in a sentence : " );


    fgets ( string , 81 , stdin );
  • dcowboyz31
    New Member
    • May 2010
    • 3

    #2
    Oh and i did put the "}" to terminate the main function just accidently left that out in the copy

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Have you considered displaying the string array after the fgets call?

      Comment

      Working...