[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

Urgent (500 points): What is _TEXT?

What does this code mean?  What is _TEXT?

How do I use it?  I get error: _TEXT is not declared in scope.  How do I fix this?
lastLineLeftOver[0] = _TEXT('\0');

Open in new window

0
boyhanquoc
Asked:
boyhanquoc
  • 3
1 Solution
 
Jaime OlivaresSoftware ArchitectCommented:
just use:
lastLineLeftOver[0] = '\0';

_TEXT is a macro used in Visual C++ to allow compatibility between Unicode and Ansi application.

0
 
MiShepsCommented:
Need to see more of the code. Looks like your missing something.
0
 
boyhanquocAuthor Commented:
Thanks, one more quick question.

If I have a main.c that uses functions declared in blank.h and defined in blank.c, how do I make them compatible with each other.

And how do I make them one program.
0
 
boyhanquocAuthor Commented:
Ok, i lied, one more, I hope.  Check out replaceNibble function, it takes 2 parameters for filenames.  It uses inFile to read and outFile to write to.

Now, I want to change the function to only take 1 parameter for filename, because I want to write back into the original inFile.

so it should be like this:  int replaceNibble(char* inputFilename, int nibbleValue, int newValue);

Should I use tmpfile()??  What would it be with tmpfile()?
int replaceNibble(char* inFile, char *outFile, int nibOldVal, int nibNewValue)
{
    FILE *from;
    FILE *fout;
    char lastLineLeftOver[32];
    char line[512];
    char outLine[512];
    char *pStr  = NULL;
    char *pStrSave = NULL;
    int leftOverLen = 0;
    int nibbleIndex = 0;
    int value = 0;
    int totalItemCount = 0;
    int outLineLen = 0;
 
    from = fopen(inFile, "r");
    fout = fopen(outFile, "w");
 
    lastLineLeftOver[0] = '\0';
    outLine[0] = '\0';
    while (fgets(&line[leftOverLen], 512 - leftOverLen, from) != NULL)
    {
        /* Process this line */
        pStr = line;
        leftOverLen = 0;
        while(pStr!=NULL && pStr!='\0')
        {
            /* Skip the font splaces */
            while(*pStr!='\0' && !isdigit(*pStr))
                pStr++;
 
                /* Get this number */
                value = atoi(pStr);
 
                /* Skip over this integer digits */
                pStrSave = pStr;
                while(*pStr!='\0' && isdigit(*pStr))
                    pStr++;
 
                /* If the very last char was a digit, then it's possible it's cutting a number while reading */
                if(*pStr=='\0' && isdigit(*(pStr-1)))
                {
                    /* Copy this cut-off string the beginning of the buffer, so that it can be processed next time. */
                    strcpy(lastLineLeftOver, pStrSave);
                    leftOverLen = strlen(pStrSave);
                    strcpy(line, lastLineLeftOver);
                    pStr = NULL;
                }
                else
                {
                    totalItemCount++;
                    for(nibbleIndex = 0; nibbleIndex<4; nibbleIndex++)
                    {
                        if(testNibble(value, nibbleIndex, nibOldVal)==1)
                        {
                            value = setNibble(value, nibbleIndex, nibNewValue);
                            printf("Item %d, nibble %d", totalItemCount, nibbleIndex);
                        }
                    }
 
                    /* write the the out buffer */
                    outLineLen = strlen(outLine);
                    sprintf(&outLine[outLineLen], "%d ", value);
                }
        }
 
        /* Write the whole line out */
        fputs(outLine, fout);
        outLine[0] = '\0';
    }
 
    /* Possibly the last value is still in the buffer */
    if(line[0]!='\0')
    {
        value = atoi(line);
        totalItemCount++;
        for(nibbleIndex = 0; nibbleIndex<4; nibbleIndex++)
        {
            if(testNibble(value, nibbleIndex, nibOldVal)==1)
            {
                value = setNibble(value, nibbleIndex, nibNewValue);
                printf("Item %d, nibble %d", totalItemCount, nibbleIndex);
            }
        }
        outLineLen = strlen(outLine);
        sprintf(&outLine[outLineLen], "%d", value);
        fputs(outLine, fout);
    }
 
    fclose(from);
    fclose(fout);
 
    return 1;
}

Open in new window

0
 
boyhanquocAuthor Commented:
nevermind, solved.
0

Featured Post

Become a Leader in Data Analytics

Gain the power to turn raw data into better business decisions and outcomes in your industry. Transform your career future by earning your MS in Data Analytics. WGU’s MSDA program curriculum features IT certifications from Oracle and SAS.  

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now