int main() { char nomeFile[]="prova.txt"; FILE* ingresso; int numParole=contaParole(nomeFile); ingresso = fopen(nomeFile, "r"); char parola[30]; char** parole=malloc(sizeof(char*)*numParole); int i=0; while(!feof(ingresso)) { fscanf(ingresso, "%s", parola); parole[i]=strdup(parola); i++; } parole=UniformaArray(parole, numParole); ArrayToFile(parole, numParole); return 0; }
void acquire_scans (void) { int color; int Nleft=0; char file [ FILENAME_MAX ]; SetCtrlAttribute (Main_pnl_handle, ERG_panel_acquire, ATTR_DIMMED, 1); SetCtrlAttribute (Main_pnl_handle, ERG_panel_abortscan, ATTR_DIMMED, 1); if (experiment==1){ GetCtrlVal (Sequence_pnl_handle, Seq_panel_seq_number, &seq_num); Nscans= seq_num*m; } else { GetCtrlVal (Main_pnl_handle, ERG_panel_nscans, &Nscans); } DirSelectPopup ("d:\\data\\test", "Select Directory", 1, 1, pathname); i=0; SetCtrlAttribute (Main_pnl_handle, ERG_panel_pause, ATTR_DIMMED, 0); SetCtrlAttribute (Main_pnl_handle, ERG_panel_abortscan, ATTR_DIMMED, 0); // start trigger SRS_flag=2; SRS_onoff(); DeleteGraphPlot (Main_pnl_handle, ERG_panel_mask_display, -1, VAL_IMMEDIATE_DRAW); if (experiment==1){ // mode sequence for (i=0;i<seq_num;i++) { for (h=0;h<m;h++){ SetCtrlIndex (Sequence_pnl_handle, Seq_panel_mask_list, h); for (k=0;k<Npixel;k++){ drive_level[k]=mask[h].voltages[k]; } display_masks(); ProcessSystemEvents(); GetLabelFromIndex (Sequence_pnl_handle, Seq_panel_mask_list, h, &mask_filename); strcpy(filename, pathname); //prepare file to write sprintf(file, "\\sequence%d_%s.txt", i, mask_filename); strcat(filename, file); data_file = OpenFile (filename, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII); //enable oscillo then wait for trigger and get ERG trace color=floor(256/Nscans)*(i*m+h); waveform(color, data_file); get_intensity(); //write header file headerfile(); //write ERG trace ArrayToFile (filename, data2fit, VAL_DOUBLE, 10000, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_SEP_BY_TAB, 100, VAL_ASCII, VAL_APPEND); nmeasure[0]=i*m+h+1; displaychannel(); Nleft=Nscans-(i*m+h); SetCtrlVal (Main_pnl_handle, ERG_panel_nremain, Nleft); ProcessSystemEvents(); if (pause_flag) { while (pause_flag) ProcessSystemEvents(); } } } } else{ // mode normal //prepare file name for acquiring data while ( i < Nscans ) { strcpy(filename, pathname); sprintf(file, "\\scope_data%d.txt", i); strcat(filename, file); data_file = OpenFile (filename, VAL_WRITE_ONLY, VAL_TRUNCATE, VAL_ASCII); color=floor(256/Nscans)*i; waveform(color, data_file); get_intensity(); headerfile(); ArrayToFile (filename, data2fit, VAL_DOUBLE, 10000, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_SEP_BY_TAB, 100, VAL_ASCII, VAL_APPEND); i++; Nleft=Nscans-i+1; SetCtrlVal (Main_pnl_handle, ERG_panel_nremain, Nleft); ProcessSystemEvents(); if (pause_flag) { while (pause_flag) ProcessSystemEvents(); } CloseFile (data_file); } } SetCtrlVal (Main_pnl_handle, ERG_panel_nremain, 0); SetCtrlAttribute (Main_pnl_handle, ERG_panel_pause, ATTR_DIMMED, 1); SetCtrlAttribute (Main_pnl_handle, ERG_panel_abortscan, ATTR_DIMMED, 1); SetCtrlAttribute (Main_pnl_handle, ERG_panel_acquire, ATTR_DIMMED, 0); // stop trigger SRS_flag=0; SRS_onoff(); ibsic(device); return; }