Solved

Urgent (500 points): What is _TEXT?

Posted on 2008-11-02
5
176 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

831 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