Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your code appears to be correct -- how was the FILE pointer opened?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yup, Narue gave you the same answer that I gave you just the other day.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Put the timer code in another thread. How to create the thread depends on the operatin system.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

"After we breached the abdominal wall to take numerous tissue samples from his small intestine, it was clear the senator was in perfect health for his age.

"for his age" is the operative phrase. That doesn't mean he is without serious health issues.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>the char ctext[n_line_text][133] is not possible, n_line_text is not const
It is possible with a c99 compliant compiler. But not very many compilers have implemented that yet.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

getline() reads 25 charcters, or up to end-of-line, which ever is shorter. In order for that to work the description field in the data file must always be 25 characters (fixed length). The newest file example you just posted has 3 words in some description fields, which tosses out my previous suggestion. Here is how I would do that NOTE: This has not been compiled or tested.

std::string line;
while( getline(fin, line) )
{
    size_t pos = 0;
     // find first non-digit character
    while( idsigit(line[pos]) )
          pos++;
    // extract pid
    nnptr->pid = atol( line.substr(0,pos).c_str());
    line = line.substr(pos+1);
    // find first digit field (end of description)
    for(pos = 0; !isdigit(line[pos]); pos++)
        ;
    // extract description
    strcpy(nnptr->description, line.substr[0,pos].c_str());
    line = line.substr(pos);
    // convert remainint integers
    strstring str(line);
    str >> nnptr->wholesale >> nnptr->markup >> nnptr->quantity;
    // add nnptr to linked list
    <snip>
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>but wrong way
Oh, now I see what you want to do. To my knowledge you can't do it. char *ctext[133]; is an array of 133 pointers but you want an array of n_lines_text number of pointers. It might be possible with a compiler that is C99 compliant, but most compilers aren't. You need char *ctext[n_lines_text]; or possibly even char ctext[n_lines_text][133];

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 77: >> fin.getline(description, 25);

Unfortunately that doesn't work because the description field is not a fixed size of 25 characters in the data file. What you need to do is just read the next two words and concantinate them together: something like this

std::string temp;
fin >> nnptr->description;
fin >> temp; temp = " " + temp;
strcat(nnptr->description, temp.c_str();
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I assume num_lines_text is the valid size of the 2d array. If so

vector<string> theList;
for(int i = 0; i < num_lines_text; i++)
    theList.push_back(text_string[i]);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are correct. Thanks. That's what I get for doing things at 2 am.
The loop can can count in either direction, but it must cover 0 through 3.
I forgot the char* assigned to &result that I was intended to index.

The following code does that you added does not take into account that the information is read from a file and not in the byte order required. I only used the array as a substitute for the data that would be pulled from the file (in the array order).

int main()
{
    unsigned char a[4] = {0XBC,0x1e,0x04,0x00};
    unsigned long n = *(unsigned long*)a;
}

It doesn't matter whether the data is read from a file or hard-code in the program ? If the data is in the wrong byte order (big/little endian problem) then it will have to be fixed before that typecast line.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't call any MS-Windows programs (such as Notepad.exe) from a 16-bit compiler because the compiler doesn't know how to do that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
int howmuchIread = 0;
	while ( ( howmuchIread = fread ( buffer, 1, READSIZE, fp ) )  != 0 )
	{
		buffer[ howmuchIread ] = 0; //place terminal character to avoid overruns

I hope you realize that the code in the last line above will likely cause buffer overflow. Lets say howmuchIread == READSIZE, which is the same as sizeof(buffer). Then buffer[howmuchIread] will be one byte beyond the end of the buffer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

And how about big/little endian problem in the Ancient Dragon's solution?..
;)

That's only a problem if the data is transferred between computers running different operating systems. But both your example and mine have that potential problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Nice piece of code. I never knew it could be (legally) done like this.
But you're assuming that a long has 4 bytes and this isn't guaranteed to be the case right?
ISO C++ guarantees that long is always at least as big as int, but an int could be 2 bytes on some systems, or am I mistaken?

The whole problem resolves around the fact that the long is 4 bytes long. Although the character array is 4 bytes, typecasting to long make no such assumption because the typecase will use however many bytes are used by the compiler to cast the array to long. If its 16-bit then the case will result is crap because the array assumed it was a 32-bit long.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

OMG This thread is just one hijack after another! Closing it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

OMG either you lied like hell to land that job or your employer is pretty darned stupid for hiring you in that position.

>>what causes do u think i need to do, to be able to achieve this.
Quit that job and go to college full time to earn a bachelor's degree. You can't learn IT overnight.

stephen84s commented: ROFL ............. :D +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

hey today my brother said other than thinking about subject u can do nothing n that`s why this profession suits me. i thought this must be nice topic to start if you were not in this field what u will do or which profession you will opt
to start with i always sing songs so may be that other thing that suits me(all say i sing well)

Are you trying to tell me that you are singing songs to yourself in school instead of listening to what your professor is telling your :-O

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

unsigned char values[4] = (char[]) 0xBC1E0400; //Read from file stream
long result;

for(int i=4;i<4;i++)
((char*)&result)[4-i] = values;

Two problems with that code
1) the for loop will never execute because i is initialized to 4 then its testing i to see if its less than 4, which it isn't.

2) result isn't an array so you can't use array subscripts on it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is one way to do it.

int main()
{
    unsigned char a[4] = {0XBC,0x1e,0x04,0x00};
    unsigned long n = *(unsigned long*)a;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem with the code I posted is that Notepad won't die if the user has to save the file first.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The getline function for the istream class returns the line in a char[]

istream& getline (char* s, streamsize n );
istream& getline (char* s, streamsize n, char delim );

There is another getline for the string class which returns the array in a string.

istream& getline( istream& is, string& s, char delimiter = '\n' );

It took me a while to figure that out also :)

Yes, and that was the second example in my previous post. There is another getline() that's not part of fstream -- it is declared in <string> header file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The file systems on all mobile hardware running Microsoft Mobile 5.0 and PocketPC are in UTC (GMT). AFAIK there is no way to make GetOpenFileName() to display anything else.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here's the long way around:
Start --> All Programs --> Accessories --> Run

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>It wont let me just use a cout statement what do I need to use

Why not? Post what you attempted to do.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No, getline doesn't work with STL string.

What! Who the hell told you such a silly thing. There are two versions of getline() -- one works with std::string and the other works with character arrays. And for character arrays your example is 100% wrong! What you posted is the syntax for std::string, not character arrays.

// getline using std::string
std::string textstring;
std::getline(file, textstring);

// getline with character array
char textstring[255];
file.getline(textstring, sizeof(textstring));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm not sure exactly what you want to do, but you could just concantinate the strings

std::string temp;
while (getline(file, temp))
{
    Uni += temp;
    cout<<"Universal Set: {"<<Uni<<"}"<<endl;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The while statement is incorrect.

while( getline(myfile, line) )
{
    // do something with this line
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is how to kill Notepad.exe

#include <windows.h>
#include <iostream>
#include <cstring>


BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam)
{
    char WindowText[255] = {0};
    GetWindowText(hwnd,WindowText,sizeof(WindowText));
    if( strstr(WindowText,"Notepad") != NULL)
    {
        std::cout << WindowText << "\n";
        SendNotifyMessage(hwnd,WM_CLOSE,0,0);
        return FALSE;
    }
    return TRUE;
}


int main()
{
   BOOL b = EnumWindows(EnumWindowsProc, 0);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well, not really. Call TermninateProcess() only if you already know the HANDLE to the process, such as when you called CreateProcess() to spawn the process. If you did not call CreateProcess() then all you can do is get the HWND of the window you want to kill and then send it a WM_CLOSE event message.

First call EnumWindows(), which will give you the HWND of every top-level window on the computer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have 64-bit Vista Home Premium with IE7 (also 64-bit). Unable to download and install flash player with that version of IE. I also have 32-bit Firefox and flash player works normally as expected with it. When I view Program and Features, I see Adobe Flash Player ActiveX and Adobe Flash Player Plugin.

Anyone know if its possible to install a version of Flash that will work with 64-bit version of the browsers?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, that can be done in a loop. If you are on MS-Windows just call win32 api function CopyFile().

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Depends on the operating system. In MS-Windows just go to Task Manager and stop it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Since you are not doing anything with those integers except output them to another file, there is no reason to convert them from char* to int.

int main ()
{
    char text[80];
    int n1, n2;
  FILE* fp = fopen("..\\TextFile1.txt", "r");
  if(fp)
  {
    while( fgets(text, sizeof(text), fp) )
    {
        if(text[strlen(text)-1] == '\n')
            text[strlen(text)-1] = 0;
        char* p1 = strtok(text,",");
        char* p2 = strtok(NULL, ",");
        char* p3 = strtok(NULL, ",");
       cout << p1 << "," << p2 << "," << p3 << "\n";

    }
  }
  fclose(fp);
  return 0;
}
Alex Edwards commented: That looks very efficient =) +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Try C style implementation. I don't know if its faster or slower so you will have to test with your huge file.

int main ()
{
    char text[80];
    int n1, n2;
  FILE* fp = fopen("..\\TextFile1.txt", "r");
  if(fp)
  {
    while( fgets(text, sizeof(text), fp) )
    {
        char* p = strtok(text,",");
        p = strtok(NULL, ",");
        n1 = atol(p);
        p = strtok(NULL, ",");
        n2 = atol(p);
       cout << text << " " << n1 << " " << n2 << "\n";
    }
  }
  fclose(fp);
  return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

His wife needs an attitude adjustment. My wife always told me "Only dead people stop looking -- looky but don't touchy."

Ezzaral commented: ++ +12
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I wasn't talking to you !!


before you talk to people, learn how to respect yourself !


STEP ASIDE !!

I, and everyone else too, realize that programming is often very frustrating. But LizR is just trying to tell you how to do that without actually doing your homework for you. And with that response and attitude you are just chopping off your own arm.

If you have to do the assignment with loops, then look in your textbook about loops. The for loop might be the type you should try. Your text book should should you several examples of loops. Yes, anyone here can tell you about them, but it is better that you look them up yourself so that you learn how to do your own research.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Clink this link then scroll down the page a little and you will find the answer to your question.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I would normally vote Republican, but this year I'm not. Why? Because McCain is just too damed old; I don't want a president who is almost 10 years older than me because 1) his health and 2) his mind. Both these issued makes it very likely that the vp will have to assume McCain's duties.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, there is a maximum size of a std::string object. Click here. The output of the example code in the URL is this:

size: 11
length: 11
capacity: 15
max_size: 4,294,967,294
Press any key to continue . . .

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what errors does your compiler produce -- and what compiler/operating system are you using ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) const char* A = a[0]; will point to the first of 25 strings in the 2d array.

2) A = x.c_str() doesn[t work because x is not c++ std::string class. character arrays like x do not have methods.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 36: case is a c++ keyword so use another variable name in that loop.

line 38: you have to put variable names inside the parentheses, not data types.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Please reread my previous answer -- I added a little more to it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Dude. READ! I already answered your questions.

There are no standard C functions to do what you want. The explicit answers depends on the operating system you are using. If MS-Windows you can use console functions to manipulate the cursor. For *nix you may have to use the curses library.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Passing back the original pointer is sometimes also used so that the function can be a nested function call. Example:

const char* foo(char *ptr)
{
    ...
    <snip>
    return ptr;
}

int main()   
{
     printf("%s\n", foo("How now brown cow."));
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't know about anyone else, but I haven't the foggiest notion of what you are asking.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

don't use the name time.h -- that's the name of standard c include header file. Name it something else.

If that doesn't fix the problems then post the code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

All right Timothy, on a more serious note from me: If you need structure in your life as Alex suggested, then join the military because they will make a man out of you. While you are there make sure you take advantage of all the educational opportunities that they will give you so that when you get out of the military you will know what you want to do with your life.

Of course the military doesn't want you if you have a lot of medical problems or mental health problems. The military wouldn't take my grandaughter because she had seen a shrink a couple times. If military is not an option for you then do something else, like joining the peace corps.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

scanf() can not be used to input text that contain spaces. Use fgets() instead.

gotoxy(x,y++); 
fgets(temp->lname, sizeof(temp->lname), stdin);
if( strlen(temp->lname)-1 == '\n')
      temp->lname[strlen(temp->lname-1)] = 0;

Since you use the above several times, you might just make it a function and call that function forf each input item

void getline(char* item, size_t itemSize)
{
    fgets(item, itemSize, stdin);
    if( item[strlen(item)-1] == '\n')
        item(strlen(item)-1) = 0;
}

...
<snip>
printf("Last name: \n");
gotoxy(x,y++); getline(temp->lname, sizeof(temp->lname));
printf("First name: \n");
gotoxy(x,y++); get;ome(temp->fname, sizeof(temp-->fname));
printf("Tel. Number: \n");
gotoxy(x,y++); get;ome(temp->telnum, sizeof(temp->telnum));
printf("Address: ");
gotoxy(x,y++); getline(temp->address, sizeof(temp->address));