This code may look really bad, i am a beginner program so tips to make my code better will help a lot. I was wondering how to make bubbleSort() modify array values globally?, at the moment I fill up my array in main, and it works into the search methods, but then i use bubbleSort() and then try and do the searches and it seems bubbleSort() didn't affect the array in main, but only kept it in the function. I have been looking around, and places say i need to malloc, if so how would i modify my code to be able to fix this? 

```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct {
   char name[10][9];
   int data[10];
}Word;

void bubbleSort (Word q);
void linearSearch(int num, Word q);
void binarySearch(int num, Word q);

int main (int argc, const char *argv[]){
    Word q;
    char txtName[9];  /* One extra for nul char. */
    int score;
    int i = 0;
    int m = 0;
    FILE *ifp, *ofp;
    ifp = fopen("Data.txt", "r");
    while (fscanf(ifp, "%8s %d", txtName, &score) == 2) {
        strcpy(q.name[i], txtName);
        printf ("Name: %s \n", q.name[i], i);
        q.data[i] = score;
        printf ("Data: %d \n", q.data[i], i);
        i++;
    }
    linearSearch(320, q);
    binarySearch(320, q);
    bubbleSort(q);
    while (m <= 9){
        printf("Name: %s, Data: %d \n", q.name[m], q.data[m]);
        m++;
    }
    return EXIT_SUCCESS;
}
void linearSearch(int num, Word q){ 
    int i = 0;
    int foundIt = 0; 
    int numNumbers = 10;
    while ((foundIt == 0) && (i <= numNumbers)){
        if (num != q.data[i]){
            i = i + 1;
        } else {
            foundIt = 1;
        }
    }
    if (foundIt == 1){
        printf("Name found at position %d \n", i + 1); 
    } else {
        printf("Required person not found \n"); 
    } 
}

void bubbleSort (Word q){
    int last = 9;
    int Swapped = 1; 
    int i = 0;
    int m = 0;
    char temp[32] = "Hello";
    int tempA;
    while (Swapped == 1){
        Swapped = 0;
        i = 0;
        while (i < last){
            if (q.data[i] > q.data[i+1]) {;
                //Copy Name of Element
                strcpy (temp, q.name[i]);
                strcpy(q.name[i], q.name[i+1]);
                strcpy(q.name[i+1] , temp);

                //Copy Data of corresponding element
                tempA = q.data[i];
                q.data[i] = q.data[i+1];
                q.data[i+1] = tempA;
                Swapped = 1; 

            } 
            i = i + 1;
        }
        last = last - 1;
    }
    linearSearch(320, q);
}

void binarySearch(int num, Word q){
    int Lower = 0;
    int Upper = sizeof(&q.data);
    int FoundIt = 0; 
    int PositionFound;
    int Middle = 0;
    while (FoundIt == 0 || (Lower > Upper) != 0){
        Middle = floor((Upper + Lower) / 2); 
        if (num == q.data[Middle]){
            FoundIt = 1;
            PositionFound = Middle;
        } else {
            if (num < q.data[Middle]){
                Upper = Middle - 1;
            } else {
                Lower = Middle + 1;
            }
        } 
    }   
    if (FoundIt == 1){
        printf("Name found at position %d \n", PositionFound + 1); 
    } else {
        printf("Required person not found \n"); 
    } 
}

```

input is:  

John 32  

Mark 12  

Matthew 29  

Luke 21  

Issac 24  

Kane 2  

Ryan 5  

Abel 10  

Adam 320  

Eve 1