Solved

Urgent (500 points): What is _TEXT?

Posted on 2008-11-02
5
175 Views
Last Modified: 2010-04-15
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
Comment
Question by:boyhanquoc
  • 3
5 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 22864428
just use:
lastLineLeftOver[0] = '\0';

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

0
 

Expert Comment

by:MiSheps
ID: 22864432
Need to see more of the code. Looks like your missing something.
0
 

Author Comment

by:boyhanquoc
ID: 22864447
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
 

Author Comment

by:boyhanquoc
ID: 22864483
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
 

Author Comment

by:boyhanquoc
ID: 22868664
nevermind, solved.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now