C++ (Cpp) strcmp Examples

C++ (Cpp) strcmp - 30 examples found. These are the top rated real world C++ (Cpp) examples of strcmp extracted from open source projects. You can rate examples to help us improve the quality of examples.
int number_read()
{
    FILE *tempfile;
    tempfile = fopen("../connection.cfg", "w+");
    if (tempfile == NULL)
    {
        printf("unable to test, cannot create new file\n");
        return 1;
    }

    char *tst_str = "4815162342\nxxx";

    fwrite(tst_str, sizeof(char), strlen(tst_str), tempfile);

    fseek(tempfile, 0, SEEK_SET);
    char *res = file_read_value(tempfile, 0);
    fail_if(strcmp(res, "4815162342") != 0);

    ssds_free(res);

    fseek(tempfile, 0, SEEK_SET);
    file_read_value(tempfile, 4);
    fail_if(strcmp(res, "481") != 0);

    ssds_free(res);
    fclose(tempfile);
    remove("../connection.cfg");

    return 0;
}
Example #2
0
void SceneParser::parseMaterials() {
    char token[MAX_PARSER_TOKEN_LENGTH];
    getToken(token);
    assert (!strcmp(token, "{"));
    // read in the number of objects
    getToken(token);
    assert (!strcmp(token, "numMaterials"));
    num_materials = readInt();
    materials = new Material*[num_materials];
    // read in the objects
    int count = 0;
    while (num_materials > count) {
        getToken(token);
        if (!strcmp(token, "Material") ||
                !strcmp(token, "PhongMaterial")) {
            materials[count] = parseMaterial();
        } else {
            printf ("Unknown token in parseMaterial: '%s'\n", token);
            exit(0);
        }
        count++;
    }
    getToken(token);
    assert (!strcmp(token, "}"));
}
Example #3
0
int login() {
    char buf[MAX_LEN];
    char motd[MAX_LEN];

    int loginSucceed = FALSE;

    Send(clientfd, "WOLFIE \r\n\r\n", strlen("WOLFIE \r\n\r\n"), 0);
    Recv(clientfd, buf, MAX_LEN, 0);

    if(strcmp(buf, "EIFLOW \r\n\r\n") == 0) {
        if(authenticateUser() == TRUE) {
            if(promptPassword() == TRUE) {
                Recv(clientfd, buf, MAX_LEN, 0);

                if(strncmp(buf, "HI ", 3) == 0 && strcmp(&buf[strlen(buf)-5], " \r\n\r\n") == 0) {
                    Recv(clientfd, buf, MAX_LEN, 0);

                    if(strncmp(buf, "MOTD ", 5) == 0 && strcmp(&buf[strlen(buf)-5], " \r\n\r\n") == 0) {
                        sscanf(buf, "MOTD %s \r\n\r\n", motd);
                        sfwrite(&Q_lock, stdout, "%s\n", motd);

                        loginSucceed = TRUE;
                        printLoginLog(auditfd, name, hostname, port, TRUE, motd);
                    }
                }
            }
        }
    }

    return loginSucceed;
}
Example #4
0
static int				/* O - Result of comparison */
index_compare(mxml_index_t *ind,	/* I - Index */
              mxml_node_t  *first,	/* I - First node */
              mxml_node_t  *second)	/* I - Second node */
{
    int	diff;				/* Difference */


    /*
     * Check the element name...
     */

    if ((diff = strcmp(first->value.element.name,
                       second->value.element.name)) != 0)
        return (diff);

    /*
     * Check the attribute value...
     */

    if (ind->attr)
    {
        if ((diff = strcmp(mxmlElementGetAttr(first, ind->attr),
                           mxmlElementGetAttr(second, ind->attr))) != 0)
            return (diff);
    }

    /*
     * No difference, return 0...
     */

    return (0);
}
Example #5
0
void saisie()
{
    const MAXPRENOM = 200 ; /* de moi */
    char prenom[MAXPRENOM], nom[MAX_NOM] ;
    struct etudiant eleve ;
    int i ;

    strcpy(eleve.nom, "début")          ;

    while(strcmp(eleve.nom,"!") != 0) /* de moi */
    {
        printf("--------------------\n") ; /* de moi */
        printf("Saisie d'un étudiant\n") ; /* de moi */
        printf("--------------------\n") ; /* de moi */
        printf("Nom ('!' pour terminer): ") ;
        scanf("%s", eleve.nom)     ;
        conv_maj(eleve.nom)        ;
        if(strcmp(eleve.nom,"!") != 0) /* de moi */
        {
            printf("Prénom : ")       ;
            scanf("%s", eleve.prenom) ;
            conv_maj(eleve.prenom)    ;
            printf("Âge : ")          ;
            scanf("%d", &eleve.age)   ;

            printf("\n")              ; /* de moi */
            tabeleve[i++] = eleve     ;
        }
    }
    nbeleves = i ;
    printf("%d élèves saisis.\n", nbeleves) ;
    a_sauvegarder = 1 ;
}
Example #6
0
struct_member *csymst_mb_by_name(ktap_state *ks,
                                 csymbol_struct *csst, const char *name)
{
    int nr = csymst_mb_nr(csst);
    int i;
    struct_member *memb;
    csymbol *cs = NULL;

    if (nr < 0) {
        kp_error(ks, "Find size of undefined struct");
        return NULL;
    }

    for (i = 0; i < nr; i++) {
        if (!strcmp(name, csymst_mb_name(csst, i)))
            return csymst_mb(csst, i);
        if (!strcmp("", csymst_mb_name(csst, i))) {
            cs = csymst_mb_csym(ks, csst, i);
            if (csym_type(cs) != FFI_STRUCT && csym_type(cs) != FFI_UNION) {
                kp_error(ks, "Parse error: non-record type without name");
                return NULL;
            }
            memb = csymst_mb_by_name(ks, csym_struct(cs), name);
            if (memb != NULL)
                return memb;
        }
    }
    return NULL;
}