Click here to Skip to main content
15,898,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to make a function that you can pass any type of array to?? Pin
John M. Drescher30-Jul-03 11:53
John M. Drescher30-Jul-03 11:53 
GeneralShellExecute and highlighting Pin
heju30-Jul-03 9:57
heju30-Jul-03 9:57 
GeneralCMainFrame Pin
act_x30-Jul-03 9:35
act_x30-Jul-03 9:35 
GeneralToolBar Pin
Anonymous30-Jul-03 8:36
Anonymous30-Jul-03 8:36 
GeneralRe: ToolBar Pin
Frank K31-Jul-03 0:50
Frank K31-Jul-03 0:50 
GeneralDialog events when in a View Pin
Anonymous30-Jul-03 8:31
Anonymous30-Jul-03 8:31 
GeneralRe: Dialog events when in a View Pin
Bob Stanneveld30-Jul-03 9:19
Bob Stanneveld30-Jul-03 9:19 
Questionfunction that doesn't care about the type in the paramater?? Pin
johnstonsk30-Jul-03 8:23
johnstonsk30-Jul-03 8:23 
Sorry the subject was hard to summerize.

I have created a function that I thought was type independent, meaning that it didn't matter what type of an array was passed to the function. It would just write the data with a comma seperation.

I have 2 structure in a class called RFMAccess:

struct TSimHeader
    {
	char   Name[47][21];
	char   Unit[47][21];
	double Min[47];
	double Max[47];
	int SignalCount;
	int SimStatus;

    }static TSimHeader_arr[10];


    struct TSimSignal
    {
       	double Value[47];
	double TimeStamp;

    }static TSimSignal_arr[10];


The data in these structures gets updated 2x a second.
I also want to write the data to a file 2x a second so, I created a function that I thought would do this without having to declare the array type. I want to be able to use this later in other projects.

Here is my function.
I am doing something incorrect here, but just not sure what it is.

ofstream fout ("test.txt");
bool firstTime = true;
int passes = 1;




void LogData::writeData(void *data){	
    int count;
    if(firstTime){
        fout<<"flight_data,";
        for(int i=0; i<RFMAccess::TSimHeader_arr[0].SignalCount; i++){
           if(i == 0){
            fout<<data[i]<<endl;
            passes++;
            if(passes == 2)
                writeData(RFMAccess::TSimHeader_arr[0].Unit);
            else if(passes == 3)
                writeData(RFMAccess::TSimHeader_arr[0].Min);
            else if(passes == 4)
                writeData(RFMAccess::TSimHeader_arr[0].Max);
            else if(passes == 5){
                firstTime = false;
                writeData(RFMAccess::TSimSignal_arr[0].Value);
            }
        }
        else
            fout<<data[i]<<",";
        }
    }
    if(!firstTime &&(flight_data->log  == true)){
         if(i == 0){
            fout<<data[i]<<endl;
            writeData(RFMAccess::TSimSignal_arr[0].Value);
         }
         else
            fout<<data[i]<<",";
    }
}


Thnaks for the help,
Steven
AnswerRe: function that doesn't care about the type in the paramater?? Pin
Brian Delahunty30-Jul-03 9:37
Brian Delahunty30-Jul-03 9:37 
GeneralRe: function that doesn't care about the type in the paramater?? Pin
johnstonsk30-Jul-03 9:46
johnstonsk30-Jul-03 9:46 
QuestionCDialogBar ????? Pin
Shay Harel30-Jul-03 8:03
Shay Harel30-Jul-03 8:03 
GeneralUnwanted color change when Edit box is ReadOnly Pin
Aidman30-Jul-03 7:07
Aidman30-Jul-03 7:07 
GeneralRe: Unwanted color change when Edit box is ReadOnly Pin
l a u r e n30-Jul-03 7:20
l a u r e n30-Jul-03 7:20 
GeneralRe: Unwanted color change when Edit box is ReadOnly Pin
Renjith Ramachandran30-Jul-03 8:13
Renjith Ramachandran30-Jul-03 8:13 
GeneralRe: Unwanted color change when Edit box is ReadOnly Pin
Aidman30-Jul-03 8:20
Aidman30-Jul-03 8:20 
GeneralRe: Unwanted color change when Edit box is ReadOnly Pin
John M. Drescher30-Jul-03 15:06
John M. Drescher30-Jul-03 15:06 
GeneralChild dialogs in Win32 Pin
bluecombtiller30-Jul-03 7:06
bluecombtiller30-Jul-03 7:06 
GeneralRe: Child dialogs in Win32 Pin
l a u r e n30-Jul-03 7:21
l a u r e n30-Jul-03 7:21 
GeneralRe: Child dialogs in Win32 Pin
bluecombtiller31-Jul-03 7:10
bluecombtiller31-Jul-03 7:10 
GeneralRe: Child dialogs in Win32 Pin
andyj1151-Aug-03 4:30
andyj1151-Aug-03 4:30 
GeneralRe: Child dialogs in Win32 Pin
bluecombtiller1-Aug-03 9:13
bluecombtiller1-Aug-03 9:13 
GeneralDynamic array initialization. Pin
73Zeppelin30-Jul-03 6:37
73Zeppelin30-Jul-03 6:37 
GeneralRe: Dynamic array initialization. Pin
John M. Drescher30-Jul-03 6:39
John M. Drescher30-Jul-03 6:39 
GeneralRe: Dynamic array initialization. Pin
73Zeppelin30-Jul-03 6:49
73Zeppelin30-Jul-03 6:49 
GeneralRe: Dynamic array initialization. Pin
John M. Drescher30-Jul-03 6:54
John M. Drescher30-Jul-03 6:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.