Error: expected identifier or ‘(’ before ‘{’ token

This is a discussion on Error: expected identifier or ‘(’ before ‘{’ token within the C Programming forums, part of the General Programming Boards category; Originally Posted by jpcanaverde I asked Google, but he didn't retreave what I want... Ignore the textouts. Tell me about ...

  1. #61
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by jpcanaverde View Post
    I asked Google, but he didn't retreave what I want... Ignore the textouts. Tell me about the pixels.
    Read the manual for Allegro, but I'm pretty sure that the first one is x, the second one is y, and the third one isn't even a pixel count.

  2. #62
    Registered User
    Join Date
    May 2010
    Posts
    30
    Ok, finally did it! I changed the textout's with images, and then inserted some sleeptime's and voilá!

    My final, working code:

    Code:
    #include <stdio.h>
    #include <allegro.h>
    
    int main(void)
    {
       BITMAP *bmp; 
       PALETTE palette; 
       allegro_init(); 
       set_color_depth(24);
       set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0); 
       install_keyboard();
    
    int sleepTime;
    
    	bmp = load_bitmap("1.bmp", palette); 
       draw_sprite(screen, bmp, 0, 255);
    	
    	sleepTime=20;
    	sleep(sleepTime);
    	
    	clear_bitmap(bmp);
    	
    	 bmp = load_bitmap("2.bmp", palette); 
       draw_sprite(screen, bmp, 0, 255);
    	 
    	 sleepTime=40;
    	sleep(sleepTime);
       
       void destroy_bitmap(bmp);
       
       bmp = load_bitmap("Super.bmp", palette); 
       draw_sprite(screen, bmp, 1, 1); 
    
       sleepTime=3;
       sleep(sleepTime);
       
       void destroy_bitmap(bmp);
       
       bmp = load_bitmap("PDA.bmp", palette); 
       draw_sprite(screen, bmp, 1, 400); 
       
       sleepTime=2;
    	sleep(sleepTime);
       
        void destroy_bitmap(bmp);
       
       bmp = load_bitmap("3.bmp", palette); 
       draw_sprite(screen, bmp, 0, 255);
       
       sleepTime=5;
    	sleep(sleepTime);
       
        void destroy_bitmap(bmp);
       
       bmp = load_bitmap("consti.bmp",palette); 
       draw_sprite(screen, bmp, 1, 1); 
    
    sleepTime=15;
    	sleep(sleepTime);
       
        void destroy_bitmap(bmp);
       
       bmp = load_bitmap("4.bmp", palette); 
       draw_sprite(screen, bmp, 0, 255);
        
        sleepTime=22;
       sleep(sleepTime);
       
        void destroy_bitmap(bmp);
       
       bmp = load_bitmap("SO.bmp", palette); 
       draw_sprite(screen, bmp, 0, 0); 
       
       sleepTime=10;
    	sleep(sleepTime);
       
        void destroy_bitmap(bmp);
       
       bmp = load_bitmap("5.bmp", palette); 
       draw_sprite(screen, bmp, 0, 255);
       
        sleepTime=12;
       sleep(sleepTime);
       
        void destroy_bitmap(bmp);
       
       bmp = load_bitmap("6.bmp", palette); 
       draw_sprite(screen, bmp, 0, 255);
         
          sleepTime=35;
       sleep(sleepTime);
       
        clear_bitmap(bmp);
       
       bmp = load_bitmap("Ubuntu.bmp",palette); 
       draw_sprite(screen, bmp, 1, 1); 
    
    	
       sleepTime=5;
    	sleep(sleepTime);
       
       void destroy_bitmap(bmp);
       
       bmp = load_bitmap("XP.bmp", palette); 
       draw_sprite(screen, bmp, 1, 40); 
    
         
       sleepTime=5;
    	sleep(sleepTime);
       
       void destroy_bitmap(bmp);
       
       bmp = load_bitmap("7even.bmp", palette); 
       draw_sprite(screen, bmp, 1, 80); 
    
    
    sleepTime=5;
       sleep(sleepTime);
       
        void destroy_bitmap(bmp);
    
      bmp = load_bitmap("7.bmp", palette); 
       draw_sprite(screen, bmp, 0, 255);
     
     sleepTime=35;
    sleep(sleepTime);
       
       void destroy_bitmap(bmp);
       
       bmp = load_bitmap("command.bmp", palette); 
       draw_sprite(screen, bmp, 8, 8); 
       
      sleepTime=3;
    	sleep(sleepTime);
       
        void destroy_bitmap(bmp);
       
       bmp = load_bitmap("8.bmp", palette); 
       draw_sprite(screen, bmp, 0, 255);
       
       sleepTime=22;
    sleep(sleepTime);
    
     void destroy_bitmap(bmp);
    
    bmp = load_bitmap("9.bmp", palette); 
       draw_sprite(screen, bmp, 0, 255);
     
     sleepTime=10;
       sleep(sleepTime);
       
        void destroy_bitmap(bmp);
       
    readkey();
       
       return 0;
    }
    END_OF_MAIN()
    Hope this helps someone. Thank you to all of you guys! You helped me a lot, without you, I'd never finish this. So, thank you.

    The program now opens a Window, displaying the text (in an image), and display the others, with intervals between each other... Just like a Presentation. In the end, it exits automatically. Just like I wanted.

    Again, THANK YOU.

    Regards,

    JPCanaverde
    Last edited by jpcanaverde; 06-05-2010 at 10:23 AM.

  3. #63
    Registered User
    Join Date
    May 2010
    Posts
    30
    Ok, noticed now that when the program gets to this part:

    Code:
    (...)
    bmp = load_bitmap("6.bmp", palette); 
       draw_sprite(screen, bmp, 0, 255);
         
          sleepTime=35;
       sleep(sleepTime);
       
        clear_bitmap(bmp);
       
       bmp = load_bitmap("Ubuntu.bmp",palette); 
       draw_sprite(screen, bmp, 1, 1); 
    (...)
    It crashes and exits. It displays the 6.bmp and does the sleeptime properly... But then it exits. I think it is the memory that is full, so it exits. It doesn't clear the bitmaps! I already tried with various and different commands, but it just don't works! The bitmaps aren't deleted!

    Can you help me, please? When I thought I finished...

    I thinked it worked before because all was running well... So I got busy, and the program had finished. So I thought it was OK, because when it goes to end, it exits. (I had something in the end to close it.)

    When I ran the program the second time, I noticed it.

  4. #64
    Registered User
    Join Date
    May 2010
    Posts
    30
    I asked for help in the Allegro forums too.

    [Help] Destroy bitmaps

    Now this is more Allegro-based... Hope someone can help me there.

  5. #65
    Registered User
    Join Date
    May 2010
    Posts
    30
    Ok, so now the program works. It was a little-little thing: The filename was named ubuntu.bmp, and in the code I had Ubuntu.bmp.

    So... The program works. That's a fact. But it just works on my computer, with Ubuntu. I tried on two different computers (one with Ubuntu, another with Windows) and it doesn't work. I really don't want to take my laptop to school...

  6. #66
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by jpcanaverde View Post
    But it just works on my computer, with Ubuntu. I tried on two different computers (one with Ubuntu, another with Windows) and it doesn't work. I really don't want to take my laptop to school...
    Presuming you mean it compiles but then seg faults -- stuff like that happens pretty easily. The problem is that when a compiler puts something together, it may put it together in such a way that some small memory overwrite/out of bounds mistake is harmless, so you won't notice it. Then it gets put together by another compiler slightly differently, and the mistake causes a seg fault.

    I've made mistakes I did not notice until the code was compiled on a third and even fourth different system.

    So you have to find the mistake and correct it. It's still certainly a mistake.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  7. #67
    Registered User
    Join Date
    May 2010
    Posts
    30
    In Windows Code::Blocks, it says something about mangled_main and winmain... I post the full error later.

Page 5 of 5 FirstFirst 12345
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  2. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  3. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 10:23 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM

Tags for this Thread


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