• C

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

boyhanquocAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.