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


C++ readFromFile函数代码示例

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


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

示例1: main

int main(int argc, char ** argv) {
	int res;
	Matrix * A = readFromFile(argv[1]);
	Matrix * b = readFromFile(argv[2]);
	Matrix * x;

	if (A == NULL) return -1;
	if (b == NULL) return -2;
	printToScreen(A);
	printToScreen(b);

	res = eliminate(A,b);
	x = createMatrix(b->r, 1);
	if (x != NULL) {
		res = backsubst(x,A,b);

		printToScreen(x);
	  freeMatrix(x);
	} else {
					fprintf(stderr,"Błąd! Nie mogłem utworzyć wektora wynikowego x.\n");
	}

	freeMatrix(A);
	freeMatrix(b);

	return 0;
}
开发者ID:fevrite,项目名称:lmp9,代码行数:27,代码来源:main.c

示例2: android_server_BatteryService_update

static void android_server_BatteryService_update(JNIEnv* env, jobject obj)
{
    setBooleanField(env, obj, ACO, gFieldIds.mAcOnline);
    setBooleanField(env, obj, USBO, gFieldIds.mUsbOnline);
    setBooleanField(env, obj, BPRS, gFieldIds.mBatteryPresent);
    
    setPercentageField(env, obj, BCAP, gFieldIds.mBatteryLevel);
    setVoltageField(env, obj, BVOL, gFieldIds.mBatteryVoltage);
    setIntField(env, obj, BTMP, gFieldIds.mBatteryTemperature);
    
    const int SIZE = 128;
    char buf[SIZE];
    
    if (readFromFile(BSTS, buf, SIZE) > 0)
        env->SetIntField(obj, gFieldIds.mBatteryStatus, getBatteryStatus(buf));
    else
        env->SetIntField(obj, gFieldIds.mBatteryStatus,
                         gConstants.statusUnknown);
    
    if (readFromFile(BHTH, buf, SIZE) > 0)
        env->SetIntField(obj, gFieldIds.mBatteryHealth, getBatteryHealth(buf));

    if (readFromFile(BTECH, buf, SIZE) > 0)
        env->SetObjectField(obj, gFieldIds.mBatteryTechnology, env->NewStringUTF(buf));
}
开发者ID:CaptJager,项目名称:prevail_cm7_config,代码行数:25,代码来源:com_android_server_BatteryService.cpp

示例3: android_server_BatteryService_update

static void android_server_BatteryService_update(JNIEnv* env, jobject obj)
{
    setBooleanField(env, obj, gPaths.acOnlinePath, gFieldIds.mAcOnline);
    setBooleanField(env, obj, gPaths.usbOnlinePath, gFieldIds.mUsbOnline);
    setBooleanField(env, obj, gPaths.batteryPresentPath, gFieldIds.mBatteryPresent);
    
    setIntField(env, obj, gPaths.batteryCapacityPath, gFieldIds.mBatteryLevel);
    setVoltageField(env, obj, gPaths.batteryVoltagePath, gFieldIds.mBatteryVoltage);
    setIntField(env, obj, gPaths.batteryTemperaturePath, gFieldIds.mBatteryTemperature);
    
    const int SIZE = 128;
    char buf[SIZE];
    
    if (readFromFile(gPaths.batteryStatusPath, buf, SIZE) > 0)
        env->SetIntField(obj, gFieldIds.mBatteryStatus, getBatteryStatus(buf));
    else
        env->SetIntField(obj, gFieldIds.mBatteryStatus,
                         gConstants.statusUnknown);
    
    if (readFromFile(gPaths.batteryHealthPath, buf, SIZE) > 0)
        env->SetIntField(obj, gFieldIds.mBatteryHealth, getBatteryHealth(buf));

    if (readFromFile(gPaths.batteryTechnologyPath, buf, SIZE) > 0)
        env->SetObjectField(obj, gFieldIds.mBatteryTechnology, env->NewStringUTF(buf));
}
开发者ID:AndrOMOD,项目名称:platform_frameworks_base,代码行数:25,代码来源:com_android_server_BatteryService.cpp

示例4: handleESOptions

void handleESOptions(ES es, std::map<std::string, std::string> config) {
  if (config.count("setup") > 0) {
    typename ES::KeyPair p = es.Setup(std::stoi(config["base_security_parameter"]));
    writeToFile(p.sk, config["secret_key_file_name"]);
    writeToFile(p.pk, config["public_key_file_name"]);
  }

  if (config.count("encrypt") > 0) {
    typename ES::PublicKey pk;
    readFromFile(pk, config["public_key_file_name"]);
    typename ES::PlainText msg;
    readFromFile(msg, config["plain_text_file_name"]);

    typename ES::CipherText ct = es.Encrypt(pk, msg);
    writeToFile(ct, config["cipher_text_file_name"]);
  }

  if (config.count("decrypt") > 0) {
    typename ES::SecretKey sk;
    readFromFile(sk, config["secret_key_file_name"]);
    typename ES::CipherText ct;
    readFromFile(ct, config["cipher_text_file_name"]);

    typename ES::PlainText pt = es.Decrypt(sk, ct);
    writeToFile(pt, config["plain_text_file_name"]);
  }
}
开发者ID:gauravjsingh,项目名称:FIFE,代码行数:27,代码来源:main.cpp

示例5: raedCipherSpec

void raedCipherSpec(const char * filePath, const char * userName , char * cipherSpec){
	
	FILE *file = fopen(filePath, "rt");

	if(file == NULL || userName == NULL){
		perror(filePath);
		return -1;
	}
	
	char name[512];
	char cipherss[20];
	int userChar;
	int exit = 0;
	
	do{
		userChar = readFromFile(file , name);
		readFromFile(file , cipherss);
		
		if(userChar <= 0)
			return;
		
		name[userChar] = '\0';

		if(strncmp(name , userName , strlen(userName)) == 0)
		{
		cipherSpec[0] = cipherss[0];
		exit = 1;			
		}
		
	}while(exit == 0);
	
	fclose(file);	
	
}
开发者ID:parzio,项目名称:crypto-secure-communication,代码行数:34,代码来源:common.c

示例6: findLeaf

    filepoint findLeaf(const KeyType &key){
        Tnode<KeyType> tempnode;
        filepoint nextp,temp;
        int keyindex;
        int keynum;
        if (rootloc != 0){
            tempnode = readFromFile(rootloc);
            temp = rootloc;
//            std::cout<<"this filepoint"<<temp<<std::endl;
//            tempnode.printData ();
//            std::cout<<"_________find______"<<std::endl;
//            tempnode.printData ();
//            std::cout<<"___________________"<<std::endl;
            while (tempnode.getLeaf ()==0){
//                std::cout<<"this filepoint"<<temp<<std::endl;
//                tempnode.printData ();
                keyindex = tempnode.getKeyIndex (key);
                keynum = tempnode.getKeyNum ();
                nextp = tempnode.getChild (keyindex);
                father[nextp]=temp;
                tempnode = readFromFile (nextp);
                temp = nextp;
            }
            return temp;
        }
        //else std::cout<<"error in index findleaf"<<std::endl;
        return 0;
    }
开发者ID:ox040c,项目名称:dmnb,代码行数:28,代码来源:BtreeIndex.hpp

示例7: readFromFile

GIFError CGIFFile::readHeader(void)
{
	GIFError status;

	///////////////////////////////
	//	Read the GIF signature.  //
	///////////////////////////////

	// Read in the GIF file signature that identifies the file as a GIF
	// file.  This will consist of one of the two 6-byte strings "GIF87a"
	// or "GIF89a", so an extra entry is required to NULL-terminate the
	// data to make it a proper string.
	char signature[7];
	status = readFromFile(signature, 6);
	if (status != GIF_Success)
		return status;
	signature[6] = '\0';
	strlwr(signature);

	// If neither of the valid signatures is present, then this is
	// not a recognized version of a GIF file.
	if (strcmp(signature, "gif87a") && strcmp(signature, "gif89a"))
		return GIF_FileIsNotGIF;


	///////////////////////////////////
	//	Read the screen descriptor.  //
	///////////////////////////////////

	// Read the image property data from the file header.
	GIFScreenDescriptor screen;
	status = readFromFile(&screen, sizeof(screen));
	if (status != GIF_Success)
		return status;

	// Calculate the color resolution of the global color table.
	// This tells the number of 3-byte entries in that table.
	int colorResolution = ((screen.PackedFields >> 4) & 0x07) + 1;
	if (colorResolution < 2)
		colorResolution = 2;

	// Check to see if a global color table is present in the file.
	// If so, then allocate a color table and read the data from
	// the file.  This global table will be used by all images that
	// do not have a local color table defined.
	if (screen.PackedFields & GIFGlobalMapPresent) {
		DWORD bitShift = (screen.PackedFields & 0x07) + 1;
		m_GlobalColorMapEntryCount = 1 << bitShift;
		status = readFromFile(m_GlobalColorMap, 3 * m_GlobalColorMapEntryCount);
		if (status != GIF_Success)
			return status;
	}

	// Record the full dimensions of the images in the file.
	m_ImageWidth  = screen.Width;
	m_ImageHeight = screen.Height;

	return GIF_Success;
}
开发者ID:basecq,项目名称:opentesarenapp,代码行数:59,代码来源:GIFFile.cpp

示例8: highscores

void highscores () {
	FILE *list,*list1;
	highscore_t *highscores, *highscores1;
	int input, i=1;
	int row=25, rowTemp=row+55, columnTemp=22, column=22;

	backgroundImage (TEXT);

	positionCursor(43,11);
	printf ("  _    _ _____ _____ _    _    _____  _____ ____  _____  ______ \n");
	positionCursor(43,12);
	printf (" | |  | |_   _/ ____| |  | |  / ____|/ ____/ __ \\|  __ \\|  ____|\n");
	positionCursor(43,13);
	printf (" | |__| | | || |  __| |__| | | (___ | |   | |  | | |__) | |__   \n");
	positionCursor(43,14);
	printf (" |  __  | | || | |_ |  __  |  \\___ \\| |   | |  | |  _  /|  __|  \n");
	positionCursor(43,15);
	printf (" | |  | |_| || |__| | |  | |  ____) | |___| |__| | | \\ \\| |____ \n");
	positionCursor(43,16);
	printf (" |_|  |_|_____\\_____|_|  |_| |_____/ \\_____\\____/|_|  \\_\\______|\n");
	positionCursor(43,17);
	printf ("                                                                ");

	positionCursor (35,19);
	printf ("REAL TIME");
	positionCursor (100,19);
	printf ("POSITIONAL");

	list = fopen ("highscore.bin","rb");
	highscores = readFromFile (list);
	list1 = fopen ("highscore1.bin","rb");
	highscores1 = readFromFile (list1);

	while (1) {
		if((highscores==null)||(highscores1==null)) break;
		positionCursor (row,column);
		printf ("%d. %.2f %s | ", i, highscores->score, highscores->name);
		printf(ctime(&(highscores->date)));
		
		positionCursor (rowTemp,column);
		column+=2;
		printf ("%d. %.2f %s | ", i++, highscores1->score, highscores1->name);
		printf(ctime(&(highscores1->date)));
		

		highscores=highscores->succ;
		highscores1=highscores1->succ;
		
	}
	dealocateList(highscores);
	fclose(list);
	fclose(list1);

	while (1) {
		input=controls(_getch());
		if ((input==PAUSE)||(input==EXIT)) break;
	}

}
开发者ID:vidorge,项目名称:PP2-MummyMaze,代码行数:59,代码来源:highscores.c

示例9: replyToFirstMessage

/**
 * Create Diffie-Hellman parameters and save them to files.
 * Compute the shared secret and computed key from the received other public key.
 * Save shared secret and computed key to file.
 */
bool replyToFirstMessage() {
    cout << "Reply To First Message" << endl;

    // Split received file into separate files
    vector<string> outputFiles;
    outputFiles.push_back(OTHER_FIRST_MESSAGE_RANDOM_NUMBER);
    outputFiles.push_back(OTHER_PUBLIC_KEY_FILE_NAME);
    vector<int> bytesPerFile;
    bytesPerFile.push_back(RANDOM_NUMBER_SIZE);
    splitFile(FIRST_MESSAGE_FILE_NAME, outputFiles, bytesPerFile);

    // Read in received Diffie-Hellman public key from file
    SecByteBlock otherPublicKey;
    readFromFile(OTHER_PUBLIC_KEY_FILE_NAME, otherPublicKey);

    // Read in received random number from file
    SecByteBlock otherFirstMessageRandomNumber;
    readFromFile(OTHER_FIRST_MESSAGE_RANDOM_NUMBER, otherFirstMessageRandomNumber);

    // Prepare Diffie-Hellman parameters
    SecByteBlock publicKey;
    SecByteBlock privateKey;
    generateDiffieHellmanParameters(publicKey, privateKey);

    // Write public key and private key to files
    writeToFile(PRIVATE_KEY_FILE_NAME, privateKey);
    writeToFile(PUBLIC_KEY_FILE_NAME, publicKey);

    // Compute shared secret
    SecByteBlock sharedSecret;
    if (!diffieHellmanSharedSecretAgreement(sharedSecret, otherPublicKey, privateKey)) {
        cerr << "Security Error in replyToFirstMessage. Diffie-Hellman shared secret could not be agreed to." << endl;
        return false;
    }

    // Compute key from shared secret
    SecByteBlock key;
    generateSymmetricKeyFromSharedSecret(key, sharedSecret);

    // Write shared secret and computed key to file
    writeToFile(SHARED_SECRET_FILE_NAME, sharedSecret);
    writeToFile(COMPUTED_KEY_FILE_NAME, key);

    // Generate random number
    SecByteBlock firstMessageRandomNumber;
    generateRandomNumber(firstMessageRandomNumber, RANDOM_NUMBER_SIZE);

    // Write random number to file
    writeToFile(FIRST_MESSAGE_RANDOM_NUMBER_FILE_NAME, firstMessageRandomNumber);

    vector<string> inputFileNames;
    inputFileNames.push_back(FIRST_MESSAGE_RANDOM_NUMBER_FILE_NAME);
    inputFileNames.push_back(PUBLIC_KEY_FILE_NAME);
    combineFiles(inputFileNames, FIRST_MESSAGE_REPLY_FILE_NAME);

    return true;
}
开发者ID:ANeeK181,项目名称:lgtm,代码行数:62,代码来源:lgtm_crypto_runner.cpp

示例10: numOfUsersFromFile

// Send List of users from login file to asking client
void ServerManager::getListUsers(User *client)
{
	int numOfusers = 0;
	numOfusers = numOfUsersFromFile();

	client->writeCommand(LIST_USERS);
	client->writeCommand(numOfusers -1);

	if (client != NULL)
		readFromFile(client);
	else
		readFromFile(NULL);

}
开发者ID:khenlevy,项目名称:Networking,代码行数:15,代码来源:ServerManager.cpp

示例11: isInCipherSpec

int isInCipherSpec(const char * filePath, const char * cipherSpec){
	FILE *file = fopen(filePath, "rt");

	if(file == NULL){
		perror(filePath);
		return -1;
	}
	
	char cipherss[20];
	int exit = 0;
	
	do{
		int read = readFromFile(file , cipherss);
		
		if(read <= 0)
			return - 1;

		if(cipherss[0] == cipherSpec[0])
			return 1;
		
	}while(exit == 0);
	
	fclose(file);	
	
}
开发者ID:parzio,项目名称:crypto-secure-communication,代码行数:25,代码来源:common.c

示例12: main

int main()
{
    int N = _5000;

    char ** content = readFromFile(N);
    //printContentToConsole(content,N);

    initHashTable(N);
    int i, aux;
    int maxColl = 0;
    nrOfResize = 0;
    float avgColl= 1;

    for (i=0; i<N; i++)
    {
        if ((i % 20) ==0)
            printf("\nElement Collisions FillFactor\n\n");
        aux = insertElement(*(content+i));
        printf("%7d %10d", i, aux);
        if (maxColl < aux)
            maxColl = aux;
        printf(" %8.2f%% \n", 100*getFillFactor());
        avgColl=(float)((((float)(avgColl)*i)+(float)aux)/(float)(i+1));


    }
    printf("\nNumber of resizes: %d\n", nrOfResize);
    printf("\nMaximal number of collisions: %d\n", maxColl);
    printf("\nAverage number of collisions: %f\n", avgColl);
    return 0;
}
开发者ID:CodeR57,项目名称:DSA-lab,代码行数:31,代码来源:main.c

示例13: main

int main(int argc, char** argv) {
    int maximumValue = 0, maximumWeight = 0, noOfItems = 0;
    int binaryString[MAXITEMS], optimalList[MAXITEMS];
    int i = 0;
    item items[MAXITEMS];

    //if a file has been specified.
    if (argc > 1) {
        readFromFile(argv[1], &maximumWeight, &noOfItems, items);
    }
        //no file specified.
    else {
        readFromConsole(&maximumWeight, &noOfItems, items);
    }

    //call the recursive function to enumerate all possibilities.
    enumItemSubset(0, binaryString, noOfItems, items, maximumWeight, &maximumValue, optimalList);

    //Print the output.
    printf("%d", maximumValue);
    for (i = 0; i < noOfItems; i++) {
        if (optimalList[i]) {
            printf(" %s", items[i].name);
        }
    }

    return (EXIT_SUCCESS);
}
开发者ID:sriramvasudevan,项目名称:coursework,代码行数:28,代码来源:main.c

示例14: openFile

void ResourceManager::loadResource( string_hash resourceId )
{
	const uint32_t index = _resources.find( resourceId.hash() );

	if( index == ResourceMap::INVALID )
		return;

	const string_hash typeId = _resources.get_value( index )->typeId;

	intrusive_node<ResourceFilter>* node = _filters.begin();
    for( ; node != _filters.end(); node = node->next() )
    {
        if( *(node->parent()) == typeId )
        {
        	const string256 filePath = _path + _resources.get_value(index)->filename;
        	const uint32_t resourceSize  = crap::fileSize( filePath.c_str() );


			file_t* resourceFile = openFile( filePath.c_str(), CRAP_FILE_READBINARY );

        	CRAP_ASSERT( ASSERT_BREAK, resourceFile != 0, "Resourcefile not found" );

        	pointer_t<void> memory = _allocator.allocate( resourceSize, 4 );

        	readFromFile( resourceFile, memory, resourceSize );
        	node->parent()->import( resourceId, memory, resourceSize, _system );

        	_allocator.deallocate( memory.as_void );
        	closeFile( resourceFile );
        }
    }
}
开发者ID:dtbinh,项目名称:crapengine,代码行数:32,代码来源:resourcemanager.cpp

示例15: replyToThirdMessage

/**
 * Decrypt received facial recognition parameters.
 * Encrypt facial recognition parameters.
 */
bool replyToThirdMessage() {
    cout << "Reply To Third Message" << endl;
    // Read session key from file
    SecByteBlock key;
    readFromFile(COMPUTED_KEY_FILE_NAME, key);

    // Read in the current initialization vector from file
    byte curIv[AES::BLOCKSIZE];
    // TODO: actually read it in
    // Set to 0 for now
    memset(curIv, 0, AES::BLOCKSIZE);

    // Decrypt received facial recognition params
    if (!decryptFile(THIRD_MESSAGE_FILE_NAME, 
            RECEIVED_FACIAL_RECOGNITION_FILE_NAME,
            key, curIv)) {
        cerr << "Security Error in replyToThirdMessage. MAC could not be verified." << endl;
        return false;
    }

    // Encrypt facial recognition params
    encryptFile(FACIAL_RECOGNITION_FILE_NAME, 
            THIRD_MESSAGE_REPLY_FILE_NAME, 
            key, curIv);
    return true;
}
开发者ID:ANeeK181,项目名称:lgtm,代码行数:30,代码来源:lgtm_crypto_runner.cpp


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