Thread: weird error..., I have no idea about this one...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    15

    weird error..., I have no idea about this one...

    Code:
    FILE *f = fopen(filename, "r");
    while(fgetc(f)<=0x20);
    while(fgetc(f)!=0x0A);
    int rows = 0;
    int collumns = 0;
    int companies = 0;
    char current = 0x00;
    char old = 0x00;
    string currentcomp = "";
    string lastcomp = "";
    bool checkcomp = true;
    while(current!=EOF) {
     current = fgetc(f);
     if(checkcomp) {
      if((current==0x09) || (current==0x0A)) {
       checkcomp=false;
       if(currentcomp!=lastcomp) {
        collumns++;
        lastcomp=currentcomp;
       }
       currentcomp="";
       rows++;
      } 
      else {
       currentcomp.append((char*)&current);
      }
     }
     if(current==0x0A) {
      checkcomp=true;
     }
    }
    That is my code... The weird thing is, I want to do a ++ on companies instead of collumns in my code, but if I use the int companies I get wrong result, renaming the var doesn't work, the only thing that works that I've figured out is to use the collumns var... I don't get this, please help...

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    78
    current should be and int.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    15
    Why? fgetc returns a char what I know of? And I just discovered that my code works if I add another integer (a dummy integer) below that int companies... I don't understand this...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Have an idea?
    By B0bDole in forum Projects and Job Recruitment
    Replies: 46
    Last Post: 01-13-2005, 03:25 PM
  2. A little problem about an idea, help please
    By louis_mine in forum C++ Programming
    Replies: 3
    Last Post: 09-10-2004, 09:52 PM
  3. Terrain engine idea
    By VirtualAce in forum Game Programming
    Replies: 15
    Last Post: 04-03-2004, 01:30 AM
  4. New idea on conveting byte to bits/bits to byte
    By megablue in forum C Programming
    Replies: 10
    Last Post: 10-26-2003, 01:16 AM
  5. totally screwed up idea
    By iain in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 08-17-2001, 12:09 PM