C++ (Cpp) atoi Examples

C++ (Cpp) atoi - 30 examples found. These are the top rated real world C++ (Cpp) examples of atoi extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
int main( int argc , char *argv[])
{
    char hostname[100];

    if ( argc >= 3 ) sprintf(hostname,argv[2]);
    else
        sprintf(hostname,"www.microsoft.com");

    if ( argc >=5 ) timeout=atoi(argv[4]);

    if ( argc >=4 ) port=atoi(argv[3]);

    //Get the DNS servers from the resolv.conf file
    if ( argc == 1 )
        get_dns_servers();
    else
        strcpy(dns_servers[0] , argv[1]);

    //Get the hostname from the terminal
    //printf("Enter Hostname to Lookup : ");
    //scanf("%s" , hostname);
    //Now get the ip of this hostname , A record
    return ngethostbyname(hostname , T_A);

}
Example #2
0
int
main(int argc, char **argv)
{
    int		i, nthreads;
    pthread_t	tid[MAXNTHREADS];

    if (argc != 3)
        err_quit("usage: incr_rwlock1 <#loops> <#threads>");
    nloop = atoi(argv[1]);
    nthreads = min(atoi(argv[2]), MAXNTHREADS);

    /* 4obtain write lock */
    Pthread_rwlock_wrlock(&shared.rwlock);

    /* 4create all the threads */
    Set_concurrency(nthreads);
    for (i = 0; i < nthreads; i++) {
        Pthread_create(&tid[i], NULL, incr, NULL);
    }
    /* 4start the timer and release the write lock */
    Start_time();
    Pthread_rwlock_unlock(&shared.rwlock);

    /* 4wait for all the threads */
    for (i = 0; i < nthreads; i++) {
        Pthread_join(tid[i], NULL);
    }
    printf("microseconds: %.0f usec\n", Stop_time());
    if (shared.counter != nloop * nthreads)
        printf("error: counter = %ld\n", shared.counter);

    exit(0);
}
Example #3
0
bool GameClass::readEntityData(std::ifstream &stream) {
    std::string line, type;
    while (std::getline(stream, line)) {
        if (line == "") {
            break;
        }
        std::istringstream sStream(line);
        std::string key, value;
        std::getline(sStream, key, '=');
        std::getline(sStream, value);
        if (key == "type") {
            type = value;
        }
        else if (key == "location") {
            std::istringstream lineStream(value);
            std::string xPosition, yPosition;
            std::getline(lineStream, xPosition, ',');
            std::getline(lineStream, yPosition, ',');
            float placeX = atoi(xPosition.c_str()) / 16 * 0.08f + 0.08f;
            float placeY = atoi(yPosition.c_str()) / 16 * - 0.08f;
            placeEntity(type, placeX, placeY);
        }
    }
    return true;
}
Example #4
0
File: honey.c Project: pbos/kth
int main(int argc, char* argv[])
{
    int bees = 4;
    if(argc > 1)
        bees = atoi(argv[1]);
    if(argc > 2)
        portions = atoi(argv[2]);

    sem_init(&filled, 0, 0);
    sem_init(&empty, 0, portions);
    sem_init(&bee_mutex, 0, 1);
    sem_init(&bear_wait, 0, 0);

    printf("There are %d bees.\n", bees);

    pthread_t bee_threads[bees];

    int i;
    for(i = 0; i < bees; ++i)
    {
        pthread_create(&bee_threads[i], NULL, bee, (void *)(i+1));
    }

    pthread_t parent;
    pthread_create(&parent, NULL, bear, NULL);

    pthread_exit(NULL);
}
Example #5
0
void Map::readMapFromFile(std::string filePath)
{
    std::vector<std::vector<std::string>> info = FileUtils::readFile(filePath, '\t');
    std::vector<std::vector<std::string>>::iterator it;
    it = info.begin();
    std::vector<std::string> arr;

    //duyet nhung dong con lai
    while(it != info.end())
    {
        arr = *it++;
        int ID_Quadtree = atoi(arr.at(0).c_str());
        int ID = atoi(arr.at(1).c_str());

        //1 so doi tuong la bound cua scene
        if (ID < 50)
        {
            //add bound cho info scene
            MapLoader::getInstance()->getInfoSceneByKey(ID)->getBoundFromFile(arr);
        } else
        {
            this->listInfoOfObject[ID_Quadtree] = arr;
            this->ID_Max ++;
        }
    }
}
Example #6
0
int main(int argc, char *argv[]) {
    /* Loop counter */
    int i;

    /* Verify the correct number of arguments were passed in */
    if(argc != 4) {
        fprintf(stderr, "USAGE:./main.out <INT> <INT> <INT>\n");
    }

    int mainSleepTime = atoi(argv[1]); /* Time in seconds for main to sleep */
    int numProd = atoi(argv[2]); /* Number of producer threads */
    int numCons = atoi(argv[3]); /* Number of consumer threads */

    /* Initialize the app */
    initializeData();

    /* Create the producer threads */
    for(i = 0; i < numProd; i++) {
        /* Create the thread */
        pthread_create(&tid,&attr,producer,NULL);
    }

    /* Create the consumer threads */
    for(i = 0; i < numCons; i++) {
        /* Create the thread */
        pthread_create(&tid,&attr,consumer,NULL);
    }

    /* Sleep for the specified amount of time in milliseconds */
    sleep(mainSleepTime);

    /* Exit the program */
    printf("Exit the program\n");
    exit(0);
}