Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Urgent (500 points): What is _TEXT?

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

856 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