Compile for Pentium HT

This is a discussion on Compile for Pentium HT within the C Programming forums, part of the General Programming Boards category; Is it possible to compile basic C-sources for to execute on PC with CPU Pentium HT with OS WinXP? (and ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Location
    Europe Cz Prague
    Posts
    14

    Compile for Pentium HT

    Is it possible to compile basic C-sources for to execute on PC with CPU Pentium HT with OS WinXP? (and on servers with more CPU's).

    The same source on PIII 233MHz with OS Win95 running and on PIV 3GHz HT with Win XP this program stops on the beginning and appeare error message.

    I used compiler Dev-C++ 5.0 Beta 9.2 and it was created as "Console application".

    Thank you for experiences.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    > program stops on the beginning and appeare error message.
    Ah, secret error messages.
    Care to elaborate?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Sep 2005
    Location
    Europe Cz Prague
    Posts
    14

    Compile for Pentium HT & XP sp2

    Code:
    /* pok1.exe */
    #include <stdio.h>
    #include <string.h>
    int main()
    {
    FILE *fr;
    char file[14]="a1.txt", line[81], COM[6]="COM15";
      if ((fr = fopen("file", "r")) != NULL);
      while(fgets(line,80,fr) != 0)
      if((strstr(line, COM)) == 0)
      printf("%s",line);
    
      printf("End\n");
      system("PAUSE");	
      return 0;
    }
    When I try to run this code, than XP generated this error message:
    <?xml version="1.0" encoding="UTF-16"?>
    <DATABASE>
    <EXE NAME="Pok1.exe" FILTER="GRABMI_FILTER_PRIVACY">
    <MATCHING_FILE NAME="Pok1.exe" SIZE="16365" CHECKSUM="0x5FCADF36" MODULE_TYPE="WIN32" PE_CHECKSUM="0x5875" LINKER_VERSION="0x10000" LINK_DATE="10/08/2005 11:00:58" UPTO_LINK_DATE="10/08/2005 11:00:58" />
    </EXE>
    <EXE NAME="ntdll.dll" FILTER="GRABMI_FILTER_THISFILEONLY">
    <MATCHING_FILE NAME="ntdll.dll" SIZE="702976" CHECKSUM="0x1A27B9BD" BIN_FILE_VERSION="5.1.2600.2180" BIN_PRODUCT_VERSION="5.1.2600.2180" PRODUCT_VERSION="5.1.2600.2180" FILE_DESCRIPTION="NT Layer DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="OS Microsoft® Windows®" FILE_VERSION="5.1.2600.2180 (xpsp_sp2_rtm.040803-2158)" ORIGINAL_FILENAME="ntdll.dll" INTERNAL_NAME="ntdll.dll" LEGAL_COPYRIGHT="© Microsoft Corporation." VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0xB79F1" LINKER_VERSION="0x50001" UPTO_BIN_FILE_VERSION="5.1.2600.2180" UPTO_BIN_PRODUCT_VERSION="5.1.2600.2180" LINK_DATE="08/17/2004 22:48:56" UPTO_LINK_DATE="08/17/2004 22:48:56" VER_LANGUAGE="Czech [0x405]" />
    </EXE>
    <EXE NAME="kernel32.dll" FILTER="GRABMI_FILTER_THISFILEONLY">
    <MATCHING_FILE NAME="kernel32.dll" SIZE="982016" CHECKSUM="0x62CA9CF6" BIN_FILE_VERSION="5.1.2600.2180" BIN_PRODUCT_VERSION="5.1.2600.2180" PRODUCT_VERSION="5.1.2600.2180" FILE_DESCRIPTION="Windows NT BASE API Client DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="OS Microsoft® Windows®" FILE_VERSION="5.1.2600.2180 (xpsp_sp2_rtm.040803-2158)" ORIGINAL_FILENAME="kernel32" INTERNAL_NAME="kernel32" LEGAL_COPYRIGHT="© Microsoft Corporation." VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0xFEB39" LINKER_VERSION="0x50001" UPTO_BIN_FILE_VERSION="5.1.2600.2180" UPTO_BIN_PRODUCT_VERSION="5.1.2600.2180" LINK_DATE="08/17/2004 22:48:56" UPTO_LINK_DATE="08/17/2004 22:48:56" VER_LANGUAGE="Czech [0x405]" />
    </EXE>
    </DATABASE>
    I do not understand this Win xml text. Why this source not run?
    Thank you for your experiences and for your help.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    > if ((fr = fopen("file", "r")) != NULL);
    Two things
    1. "file" is not the same as file, which is the name of the variable containing the string a1.txt
    2. The ; at the end makes the whole test useless. You compare the file pointer with NULL, then do nothing. The rest of the code goes on to try and read from a NULL file pointer.

    Always use braces, it saves confusion later on
    Code:
      if ((fr = fopen("file", "r")) != NULL) {
        while(fgets(line,sizeof(line),fr) != NULL ) { /* note sizeof */
          if ( (strstr(line, COM)) == NULL ) {
            printf("%s",line);
          }
        }
      }
      printf("End\n");
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Sep 2005
    Location
    Europe Cz Prague
    Posts
    14
    Thank you very much for example and for your time.
    Problem was really in error in my code and not problem with platform (XP & HT) as I thought.

    In function "fgets(line,80,fr)" I use real integrer 80 for to define to read max. characters from one line.
    I think that when I use "sizeof(line)" than is posible that char-variable can be overflow out of defined memory space when it will be more than 80 characters on one line, when I define this statical variable with value 81 Bytes. I hope that it is correct.

    I have another problem (but it is for new thread).

    Now our code printing each line from input text-file when line contents string from COM variable:
    Code:
    #include <stdio.h>
    #include <string.h>
    int main()
    {
    FILE *fr;
    char file[14]="a1.txt", line[81], COM[6]="COM15";
    
      if ( (fr = fopen(file, "r")) != NULL) {
        while(fgets(line, 80, fr) != NULL ) {
          if ( (strstr(line, COM)) != NULL) {
             printf("%s", line);
          }
        }
      }
    }
    When input text-file contents characters 0D 0A (in HEX) than WHILE-test finish. But I would like to test until the truly end of file.
    Probably I need to change "while(fgets(line, 80,fr) != NULL )" but I do not how.
    Maybe with EOF or feof(). Could you help me please how it is possible to make it? I am not succesful meantime.

    Than I need to solve another problem:
    If "(strstr(line, COM)" is true, than I need to jump -200 lines and apply another search - "(strstr(line, date)" where "date" is defined string eg. "Dec 09". This new search I need for 400 next lines and then I need to continue with first search etc. Maybe it is too complicated..

    I tried to solve with "fseek(fr, (-200*80), SEEK_CUR);" where -200 is -200lines * 80 characters per one line, because I do not need to jump exactly on -200 line. But maybe exist some function for count lines, maybe it is possible to apply "fgets" but I do not know how to jump back in file. Then I tried to use :
    Code:
    if(strstr(line, date) != NULL) {
    for(i=0;i<400;i++) {
      fgets(line, 80, fr);    /* read next 400 lines*/
      if(strstr(line, date) != NULL)    /* if line contents string "date" */
         printf("%s", file);   /*print filename that is suitable with conditions*/
    } }
    I do not know if I can want to help so much...
    Maybe I must divide these problems to more threads.
    Thank you for your understanding and your help.

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,045
    Code:
    printf("%s", line);
    ->
    Code:
    printf("%s\n", line);
    ?

    Code:
    char line[81];
    while(fgets(line, 80, fr) != NULL ) {
    line doesn't have to be 81 chars long. And you can actually use sizeof to figure out the size of a character array.
    Code:
    char line[80];
    while(fgets(line, sizeof(line), fr)) {
    And you should close the file with fclose(file_handle), too.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    > When input text-file contents characters 0D 0A (in HEX) than WHILE-test finish.
    > But I would like to test until the truly end of file.
    I don't understand you.
    The while loop as posted will read each line until the end of the file.

    > If "(strstr(line, COM)" is true, than I need to jump -200 lines and apply another search
    You seem to be in some doubt as to how many lines to skip.
    How about
    Code:
        enum { FIND_COM, FIND_DATE } state = FIND_COM;
        while(fgets(line, sizeof(line), fr) != NULL ) {
          if ( state == FIND_COM && (strstr(line, COM)) != NULL) {
            printf("%s", line);
            state = FIND_DATE;
          }
          if ( state == FIND_DATE && (strstr(line, "date" ) != NULL) {
            printf("%s", line);
            state = FIND_COM;
          }
        }
    You don't have to worry about counting lines or anything - the program just toggles between looking for COM and looking for "date"
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Registered User
    Join Date
    Sep 2005
    Location
    Europe Cz Prague
    Posts
    14

    In text-file A1 in Hex stopped fgets

    Thank you very much Salem, you are so kind that you have a time to help others!! and you are so clever with C programming!
    Your idea is the best and function perfectly!

    I cannot find reason why "fgets" stopped reading when in text-file A1 in hexa occured.

    When I compile this code:
    Code:
    #include <stdio.h>
    #include <string.h>
    int main()
    {
    FILE *fr;
    char file[14]="a3.txt", line[81], COM[6]="COM15";
    
      if ( (fr = fopen(file, "r")) != NULL) {
        while(fgets(line, 80, fr) != NULL ) {
          if ( (strstr(line, COM)) != NULL) {
             printf("%s", line);
          }
        }
      }
      fclose(fr);
      printf("\n...End\n");
      system("PAUSE");	
      return 0;
    }
    And run it with text file "a3.txt" with content:
    Start of test-file 1.test COM15
    DL 1A  2.test COM15 after A1 (in HEX)
    End of test-file 3.test COM15
    "fgets" stopped on ""= A1 in Hexa. When I delete this character or A1 in Hexa, than "fgets" stopped reading on the end of file.

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    > A1 in Hexa. When I delete this character or A1 in Hexa
    You mean 0x1A, which in old DOS was the actual end of file marker when DOS actually used a special character to mark the end of file. It was a dumb idea then and unfortunately the baggage of the past is still with us.

    On my Linux box, it makes no difference whether there is a control character in there or not.

    You might try opening the file in binary mode
    if ( (fr = fopen(file, "rb")) != NULL)
    Which should stop it interpreting the 0x1A character as end of file, but it will also stop fgets() from translating DOS newlines (\r\n) into the standard (\n), so bear this in mind if you're trying to remove the newline from the end of a line.

    You might want to look at what created this file in the first place, since it looks like the result of a poor attempt to join two files together.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C and C++ compile speed
    By swgh in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-02-2007, 01:37 PM
  2. Compile as you type
    By Rocketmagnet in forum A Brief History of Cprogramming.com
    Replies: 33
    Last Post: 12-07-2006, 12:36 PM
  3. How to compile mfc libs from platform sdk
    By tjcbs in forum Windows Programming
    Replies: 6
    Last Post: 11-19-2006, 07:20 AM
  4. Compile crashes certain windows
    By Loduwijk in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2006, 08:05 PM
  5. How can I compile C or C++ with Visual Studio .NET?
    By Dakkon in forum C Programming
    Replies: 8
    Last Post: 02-11-2003, 01:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21