当前位置: 首页>>代码示例>>C++>>正文


C++ printData函数代码示例

本文整理汇总了C++中printData函数的典型用法代码示例。如果您正苦于以下问题:C++ printData函数的具体用法?C++ printData怎么用?C++ printData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了printData函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main (int argc, char **argv)
{
	struct sembuf buf = {0, 0, 0}; //declaration buf structure
	
	int semid = createSem(PATH, PROJECTID, SEMVALUE, IPC_CREAT | WRITEREADATT); //create semaphore

	switch(fork())
	{
		case -1: //if fork error
			perror(FORKERROR);
			exit(1);
			break;
		case 0: 
			printData(semid); //print process id and sem data
			buf.sem_op = CLOSE; // close semaphore
			if(semop(semid, &buf, 1) == -1) // send cmd
			{
				perror(SEMOPERROR);
				exit(EXIT_FAILURE);
			}
			criticalSection(); // do sth
			printData(semid); //print process id and sem data
			buf.sem_op = OPEN; // open semaphore
			if(semop(semid, &buf, 1) == -1) // send cmd
			{
				perror(SEMOPERROR);
				exit(EXIT_FAILURE);
			}
			break;
		default:
			printData(semid); //print process id and sem data
			buf.sem_op = CLOSE; // close semaphore
			if(semop(semid, &buf, 1) == -1) // send cmd
			{
				perror(SEMOPERROR);
				exit(EXIT_FAILURE);
			}
			criticalSection();  // do sth
			printData(semid); //print process id and sem data
			buf.sem_op = OPEN; // open semaphore
			if(semop(semid, &buf, 1) == -1) // send cmd
			{
				perror(SEMOPERROR);
				exit(EXIT_FAILURE);
			}
			printf(PARENTEND); //end of parent
			printData(semid); //print process id and sem data
			if(wait(NULL) == -1) // wait for children
			{
				perror(WAITERROR);
				exit(EXIT_FAILURE);
			}
			printf(SEMDELETE, semid); 
			deleteSem(semid); // delete sem
			
			break;
	}
	
	return 0;
}
开发者ID:Bajowy,项目名称:Systemy-Operacyjne,代码行数:60,代码来源:main.c

示例2: write_frame

/* Print the computed matrix at the given time step all processes
 * should send their local data to process rank 0 which is responsible
 * for printing */
void write_frame(int time) {
  // sends data row by row
  if (rank != 0) {
    for (int i=0; i<nyl; i++)
      MPI_Send(&u_curr[i+1][1], nxl, MPI_DOUBLE, 0, DATAPASS, comm);
  } else {
    printf("\n-------------------- time step:%d --------------------\n", time);
    for (int i=0; i < NPROCSY; i++) {
      int numRows = countRowForProc(i*NPROCSX);

      for (int j=0; j < numRows; j++) {
        for (int k=0; k < NPROCSX; k++) {
          int curr_rank = i*NPROCSX + k;

          if (curr_rank!=0) {
            int senderx = firstColForProc(curr_rank);
            int sendery = firstRowForProc(curr_rank);
            int senderNxl = countColForProc(curr_rank);

            MPI_Recv(recvbuf, senderNxl, MPI_DOUBLE, curr_rank, DATAPASS, comm, MPI_STATUS_IGNORE);
            printData(time, senderx, senderNxl, sendery+j, recvbuf);
          } else {
            printData(time, firstCol, nxl, firstRow+j, &u_curr[j+1][1]);
          }
        }
        printf("\n");
      }
    }
  } 
}
开发者ID:arnabd88,项目名称:CIVL-CS6110,代码行数:33,代码来源:diffusion2dBad.c

示例3: main

int main() {
    srand((unsigned) time(NULL));

    buf = initBuf(BUFSIZE, BLKSIZE);

    initData();

    //输出R的内容
    //printData(R_START);
    //输出S的内容
    //printData(S_START);

    //找到R.A = 40
    int addr_find_R_A = findfirst(R_START, 40);
    printData(addr_find_R_A);

    //找到S.C = 60
    int addr_find_S_C = findfirst(S_START, 60);
    printData(addr_find_S_C);


    //R.A投影
    int projection_R_A = projection(R_START);
    printData(projection_R_A);
    printf("NUM = %d\n", BLKNUM);
    //R.A连接S.C
    int r_join_s = join(R_START, S_START);
    //printData(r_join_s);

    //printf("%d\n", BLKNUM);
    return 0;
}
开发者ID:silent1993,项目名称:c-language,代码行数:32,代码来源:main.cpp

示例4: printData

void 
PrintVisitor::visit(DerGtime& derGtime, ndnboost::any param)
{
  const string& indent = ndnboost::any_cast<const string&>(param);
  
  printData(derGtime.getHeader(), indent);
  printData(derGtime.getPayload(), indent + "   ");
}
开发者ID:doudouOUC,项目名称:ndn-cpp,代码行数:8,代码来源:print-visitor.cpp

示例5: sort_test

void sort_test ( void (*q) (int data[], int left, int right), int dataSet[], int dataLen )
{
	if( q == quicksort )
		printf( "quicksort\n" );
	else if(q == mergesort)
		printf( "mergesort\n " );

	printf( "Original data:\t" );
	printData( dataSet, dataLen );

	q( dataSet, 0, dataLen-1 );

	printf( " Sorted data:\t" );
	printData( dataSet, dataLen );
}
开发者ID:seungzzang,项目名称:alg,代码行数:15,代码来源:main.cpp

示例6: main

int main()
{
	char selection[1];
	int i, dataSize;
	while(1)
	{
		printf("\n1. Sort data by the float value & print high to low\n");
		printf("2. Sort data by the float value & print low to high\n");
		printf("3. Sort data by the int value & print high to low\n");
		printf("4. Sort data by the int value & print low to high\n");
		printf("5. Exit\n");
		scanf("%s", selection);
		i = atoi(selection);
		if (i==1)
		{
			dataSize = copyToArray();
			sortByFloat(dataSize, i);
			printData(dataSize);
		}
		else if (i==2)
		{
			copyToArray();
			sortByFloat(dataSize, i);
			printData(dataSize);
		}
		else if (i==3)
		{
			copyToArray();
			sortByInt(dataSize, i);
			printData(dataSize);
		}
		else if (i==4)
		{
			copyToArray();
			sortByInt(dataSize, i);
			printData(dataSize);
		}
		else if (i==5)
		{
			break;
		}
		else
		{
			printf("Invalid selection (1-5)");
		}
	};
	return 0;
}
开发者ID:ryane22,项目名称:CS230,代码行数:48,代码来源:Evenstad-HW2.c

示例7: main

int main(void) {
  date today = {21,4,2016};
  int n = 0;
  char buffer[MAX_BUFFER_SIZE];
  int rtn;

  printf("How many teachers to introduce?\n");
  do {
    fgets(buffer, MAX_BUFFER_SIZE, stdin);
    rtn = sscanf(buffer, "%d",&n);
  } while(rtn != 1);

  teacher *t = (teacher *) malloc(n*sizeof(teacher));
  if(t == NULL) {
    printf("Not enough memory\n");
    exit(1);
  }
  for(int i=0; i < n; i++) {
    readTeacher(&t[i], today);
  }
  orderByAge(t, n);
  printData(t, n);

  free(t);
  return 0;
}
开发者ID:MiguelFreire,项目名称:ProgMEEC2015-2016,代码行数:26,代码来源:ex2.c

示例8: main

int main() {
    std::unordered_map<std::string, std::vector<int>> data;
    std::vector<std::string> fileAsAnArray; // For testing
    // Read from file and build a mapping of words to sets of line numbers
    std::ifstream fileIn;
    fileIn.open("input.txt");
    std::string currWord;
    int i = 0;
    while (fileIn >> currWord) {
        data[currWord].push_back(i++);
        fileAsAnArray.push_back(currWord); // For testing
    }
    fileIn.close();
    printData(data);
    // For each word, test how close it is to every other word
    for (auto it1 = data.begin(); it1 != data.end(); ++it1) {
        for (auto it2 = data.begin(); it2 != data.end(); ++it2) {
            std::cout << "Distance between " << it1->first << " and " << it2->first << " is ";
            auto d1 = findDistanceBetween(it1->first, it2->first, data);
            auto d2 = testFindDistanceBetween(it1->first, it2->first,
                                              fileAsAnArray);
            if (d1 != d2) { assert(0); }
            std::cout << d1 << std::endl;
        }
    }
    return 0;
}
开发者ID:chrzhang,项目名称:abc,代码行数:27,代码来源:main.cpp

示例9: main

int main()
{
  struct Employee emps[SIZE] = { { 98401, 10.60 },
                             { 526488, 9.75 },
                             { 765349, 10.50 },
                             { 34645, 12.25 },
                             { 127615, 8.35 } };

  for (int i = 0; i < SIZE; ++i){
    emps[i].hours = getHours(emps[i]);
    emps[i].overtime = getOvertimeHours(emps[i]);  /* Calculate total amount of overtime hours */
    emps[i].overtimePay = getOvertimePay(emps[i]);  /* Calculate total amount of overtime pay, if necessary */
    emps[i].gross = getGross(emps[i]); /* Calculate gross pay */
  }

  printData(emps);

  /* Calculate the total gross pay per employee 
  for (int i = 0; i < SIZE; i++)
  {
    hours[i] = getHours(clockNumber[i]);
    overtime[i] = getOvertimeHours(hours[i]);  /* Calculate total amount of overtime hours 
    overtimePay[i] = getOvertimePay(overtime[i], wage[i]);  /* Calculate total amount of overtime pay, if necessary 
    gross[i] = getGross(hours[i], overtimePay[i], wage[i]); /* Calculate gross pay 
  }

  printData(clockNumber, wage, hours, overtime, gross);
  */
  return(0);
}
开发者ID:kbaker4,项目名称:C-Class,代码行数:30,代码来源:Homework5.c

示例10: TestMoveWhenDestinationDirectoryDoesNotExist

void TestMoveWhenDestinationDirectoryDoesNotExist()
{
    std::cout << "PrintDataDirectoryUT TestMoveWhenDestinationDirectoryDoesNotExist" << std::endl;
    
    Copy("resources/slices/slice_1.png", testDataDir);
    Copy("resources/slices/slice_2.png", testDataDir);
   
    PrintDataDirectory printData(testDataDir);

    if (printData.Move("bogus"))
    {
        std::cout << "%TEST_FAILED% time=0 testname=TestMoveWhenDestinationDirectoryExists (PrintDataDirectoryUT) "
                << "message=Expected Move to return false, got true" << std::endl;
        mainReturnValue = EXIT_FAILURE;
        return;
    }

    // Verify that PrintData instance knows where its data resides after failure to move
    int expectedLayerCount = 2;
    int actualLayerCount = printData.GetLayerCount();
    if (expectedLayerCount != actualLayerCount)
    {
        std::cout << "%TEST_FAILED% time=0 testname=TestCreateFromNewDataWhenDownloadDirectoryContainsTarGzFile (PrintDataDirectoryUT) "
                << "message=Layer count incorrect after failing to move print data, expected "
                << expectedLayerCount << ", got " << actualLayerCount << std::endl;
        mainReturnValue = EXIT_FAILURE;
        return;
    }
}
开发者ID:AllenMcAfee,项目名称:ember-firmware,代码行数:29,代码来源:PrintDataDirectoryUT.cpp

示例11: printStack

void printStack(stack* s){

  if(emptyStack(s) == 1){

    printf("\nThe stack is empty.\n");
    return;
  }
  stack* tempS = createStack();
  dnode* tempN = frontStack(s);
  data* d = createData(tempN->d->i1,tempN->d->i2,tempN->d->f1);
  while(emptyStack(s) != 1){

    tempN = frontStack(s);
    printData(tempN->d);
    d = createData(tempN->d->i1,tempN->d->i2,tempN->d->f1);
    pushStack(tempS,d);
    popStack(s);
  }
  while(emptyStack(tempS) != 1){

    tempN = frontStack(tempS);
    d = createData(tempN->d->i1,tempN->d->i2,tempN->d->f1);
    pushStack(s,d);
    popStack(tempS);
  }
  return;
}
开发者ID:dmcarr92,项目名称:Sophomore-Year-C-CPP,代码行数:27,代码来源:stack.c

示例12: raw

void ofxTouchBoard::printRawData(float x, float y){
	serial.lock();
		vector<ofxTB::Electrode> raw(serial.getData());
	serial.unlock();
	
	printData(raw, x, y);
}
开发者ID:elaye,项目名称:ofxTouchBoard,代码行数:7,代码来源:ofxTouchBoard.cpp

示例13: while

void Transmitter::readPendingDatagrams()
{
  while (socket.hasPendingDatagrams()) {
	QByteArray datagram;
	QHostAddress sender;
	quint16 senderPort;

	qDebug() << "in" << __FUNCTION__;

	datagram.resize(socket.pendingDatagramSize());
	
	int rx = socket.readDatagram(datagram.data(), datagram.size(), &sender, &senderPort);
	if (rx == -1) {
	  qWarning() << "Failed to readDatagram:" << socket.errorString();
	} 

	payloadRecv += rx;
	totalRecv += rx + 28; // UDP + IPv4 headers

	qDebug() << "Sender:" << sender.toString() << ", port:" << senderPort;
	printData(&datagram);

	parseData(&datagram);
  }
}
开发者ID:snowcap-electronics,项目名称:snowcap-controller,代码行数:25,代码来源:Transmitter.cpp

示例14: eeprom_read_byte

void DataWarehouse::updateDate( uint16_t year, uint8_t month, uint8_t date )
{
    uint8_t j, k;
    uint8_t todayIndex;


    todayIndex = eeprom_read_byte( (const uint8_t *)STORE_ADDR_TODAYINDEX );

    eeprom_write_byte( (uint8_t *)STORE_ADDR_VALIDFLAG, ~DATA_VALID );
    writeDateInfo( todayIndex, year, month, date );   //record end date, display end date

    todayIndex = (todayIndex+1) % DATA_SAVE_DAYS;
    DBG_PRINTLN_VAR(todayIndex,DEC);

    eeprom_write_byte( (uint8_t *)STORE_ADDR_TODAYINDEX, todayIndex );
    writeDateInfo( todayIndex, year, month, date );   //record start date, only used internally

    for ( j = 0; j < DATA_TYPE_MAXNUM; j++ )
    {
        for ( k = 0; k < SAMPLE_TIMES_PERDAY; k++ )
        {
			writeData( INVALID_INT16, todayIndex, j, k );
        }
    }

    eeprom_write_byte( (uint8_t *)STORE_ADDR_VALIDFLAG, DATA_VALID );


#if _DEBUG
    printData(1);
#endif


}
开发者ID:pookiemaker,项目名称:Reviews,代码行数:34,代码来源:WeatherStation.cpp

示例15: intialize

int intialize(char metaFile[], char dataFile[]) {
	S_table table;
	//Abre o arquivo de metadados
	FILE *F_meta = fopen(metaFile, "rb");
	//Verifica por erro na leitura do arquivo de metadados
	if(F_meta == NULL)
		return 1;
	//Pega a quantidade de campos contido no arquivo de metadados
	table.fieldCount = getFieldCount(F_meta);
	//Aloca N quantidade de campos, de acordo ao que foi lido do arquivo
	table.fields = (S_field *) malloc(sizeof(S_field) * table.fieldCount);
	//A função getFields lê do arquivo de metadados todos os dados dos campos e armazena-os na estrutura
	getFields(F_meta, table.fields,  table.fieldCount);
	//O arquivo de metadados é fechado
	fclose(F_meta);
	//Abre o arquivo de dados
	FILE *F_data = fopen(dataFile, "rb");
	//Verifica por erro na leitura do arquivo de dados
	if(F_data == NULL)
		return 2;
	//A função printData é chamada para imprimir os dados do arquivo de dados, de acordo com a estrutura informada em &table
	printData(&table, F_data);
	//Fecha o arquivo de dados
	fclose(F_data);
	return 0;
}
开发者ID:raphaelmacsabpf,项目名称:UFFS,代码行数:26,代码来源:bib.c


注:本文中的printData函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。