Call function from function - how to pass correctly

I'm having a lot of trouble with trying to write the syntax for one of my codes.

The main problem I'm having is calling the trimField() function

The trimFrield() function is called from my csvRecord transformDataToCSV() function, which is a structure type. Those are the variables being passed to trimField(). Here it what I have so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

// For the required data members, Name, Id, Score, call trimField function to remove trailing spaces and place data into csvRecord, copy entire array
   // of answers to csvRecord and return record
csvRecord transformDataToCSV(Scantron &inputRecord){
    csvRecord outputRecord;
    trimField(inputRecord.Name[21], outputRecord.Name[21]);
    trimField(inputRecord.Id[11], outputRecord.Id[11]);
    trimField(inputRecord.score[4], outputRecord.score[4]);
    for(int i = 0; i < 60; ++i){
        outputRecord.answerArray[i] = inputRecord.answerArray[i];
        trimField(inputRecord.answerArray[61], outputRecord.answerArray[61]);
    }

    return outputRecord;
}


// Remove trailing spaces from fieldIn cstring and place in fieldOut cstring
// If entire field is blank place one space followed by '\0'
void trimField(char fieldIn[], char fieldOut[] )   {
    for(int i = 0; i < 150; i++)    {
        if(fieldIn[i] != ' ')   {
            strncpy(fieldIn, fieldOut, 150);
        }
    }
}



The file we are trimming looks like this. It includes extra variables but only certains ones are passed to fieldIn:

1
2
3
4
5
6
 1         2         3         4         5         6         7         8         9         0         
123456789012345678901234567890123456789012345678901345678901234567890123456789012345678901234567890123456
BROWN DANIELLA                 810805748            562431322143323235411221 4213414131344422312122      
DEREK SAMATHA I                                 00210011313243433233344312212321342123  14212224242131121
SIMPSON BRETT                                       3844342323232233 33412342212342113221331132411112132 
TOMATO A LUKE                  811327785 15328  003 4214341213331232354112432321532412124211142232213242 
Last edited on
I had to redo it because my question changed, and so the first title was not correct anymore and it won't let me edit the title
Topic archived. No new replies allowed.