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; THANK YOU. Now it runs, but not as I thought it would. It was supposed to be like a doc. ...

  1. #31
    Registered User
    Join Date
    May 2010
    Posts
    30
    THANK YOU. Now it runs, but not as I thought it would.

    It was supposed to be like a doc. It would print the text and the images. It would display the first image at up, and the following text and images down, and I could scroll to see the text and the images. Now it runs like a super fast slide show. I don't mind it is a slide show, but it is super fast, I can't read it...

    I will try and search, but don't know WHAT to search for... That's difficult. Maybe I have to put a loop, like, when I press the enter key, it goes to the next image... Complicated. I will search, then, but any help is appreciated.

    Good lunch! And thank you again, you're the man!

  2. #32
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    On Linux, sleep(int seconds) is your friend...so say you want a 5 second pause between images:
    Code:
    int sleepTime = 5;
    ..show some image
    sleep(sleepTime);
    .. show some other image
    sleep(sleepTime);
    etc.
    Anyhow, glad it runs..
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  3. #33
    Registered User
    Join Date
    May 2010
    Posts
    30
    I compiled it to sh and does the same.

  4. #34
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    sh? Whats that?
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  5. #35
    Registered User
    Join Date
    May 2010
    Posts
    30
    I mean... .sh. Linux executable. Now I'm trying to put a sleep between every image/text...

  6. #36
    Registered User
    Join Date
    May 2010
    Posts
    30
    .sh is a Linux executable. I did a sleep between images/text... Now the images display properly, but the text doesn't show up. I tried with the normal printf and textout (allegro).

    But we have made some progresses... I can see the images perfectly, with time between each other, by the order I puted. The problem now is the text. I can't see it.

    But thank's, without all you guys (especially you, jeff) I couldn't be where I am now.

  7. #37
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    I know sh is a linux shell but I didn't understand the part about you compiling your project "to" it. But whatever, glad its working....I know next to nothing about graphics stuff (see my caveat about doing systems work)....good luck in any event.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  8. #38
    Registered User
    Join Date
    May 2010
    Posts
    30
    Instead of building an exe, building an sh.

    But text isn't about graphics. Just kidding. Thank's for all.

    So... Can somebody help me? My present code:

    Code:
    //Este programa foi feito por X.
    //Notas:
    //O comando printf introduz texto para o ecrã. O "\n" significa introduzir numa nova linha.
    //Já pus o título. Seguir o seu exemplo. Meter o resto por baixo. Não mexer nas outras coisas.
    //Have fun!
    //P.S.
    //O texto que começa com "//" são comentários. Não são interpretados pelo compilador, e não aparecem no programa em si.
    
    #include <stdio.h>
    #include <allegro.h>
    
    int main(void)
    
    {
       BITMAP *bmp; 
       PALETTE palette; 
       allegro_init(); 
       set_color_depth(24);
       set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0); 
       install_keyboard();
    
    int sleepTime = 1;
    
       bmp = load_bitmap("PC.bmp", palette); 
       draw_sprite(screen, bmp, 0, 0); 
    
    sleep(sleepTime);
    
       printf( "Linguagem Binária\n" );
       printf("Trabalho realizado por:\n");
       printf("Neste trabalho vou tratar sobre a linguagem binária, falar sobre a sua história, como é constituída, os vários tipos de coisas que existem...\n");
       printf("Os computadores nasceram em 4000 a.C. Na verdade, não era bem um computador. Mas era o iníco de uma nova era.\n");
       printf("Este aparelho era muito simples, e chamava-se ÁBACO.\n");
       printf("Este computador mecânico foi criado por Charles Babbage.\n");
       printf("Mas não estamos aqui para falar de ábacos tão antigos, pois não? Por isso vamos continuar.");
       printf("Começemos pela definição de um computador. Um computador é uma máquina capaz de de tratar e processar dados automáticamente.\n");
       printf("Um computador tanto pode ser um ábaco (como vimos anteriormente), uma calculadora, um computador analógico ou um computador digital.\n");
       printf("Os computadores pessoais e os portáteis estão associados à Era da Informação (ou à Internet).\n");
       printf("Os computadores evoluiram de tal forma que chegam a ser pequenos dispositivos muito capazes, ou grandes monstros!\n");
    	sleep(sleepTime);
       bmp = load_bitmap("Super.bmp", palette); 
       draw_sprite(screen, bmp, 0, 0); 
    sleep(sleepTime);
    	
       bmp = load_bitmap("PDA.bmp", palette); 
       draw_sprite(screen, bmp, 0, 0); 
    sleep(sleepTime);
       printf("O computador é constituído por:\n");
    	sleep(sleepTime);
       bmp = load_bitmap("consti.bmp",palette); 
       draw_sprite(screen, bmp, 0, 0); 
    sleep(sleepTime);
       printf("O SISTEMA OPERATIVO\n");
       printf("...\n");
       printf("O Sistema Operativo é a ponte entre o hardware e os programas. Gerencia a memória, o disco, os periféricos...\n");
       printf("Fornece uma interface entre o computador e o utilizador.\n");
    	sleep(sleepTime);
       bmp = load_bitmap("SO.bmp", palette); 
       draw_sprite(screen, bmp, 0, 0); 
    sleep(sleepTime);
       printf("Existem vários tipos de SOs (ou OS, no Inglês).\n");
       printf("Cada um oferece funcionalidades diferentes. Uns oferecem mais visual, outros mais performance... \n");
       printf("...\n");
       printf("Exemplos:\n");
       printf("...\n");
       printf("Windows\n");
       printf("Mac\n");
       printf("Linux\n");
       printf("Unix\n");
       printf("Solaris\n");
       printf("E muitos, muitos outros...\n");
       printf("...\n");
       printf("Como podem ver no gráfico acima, o Windows é o mais utilizado. Mas não quer dizer que seja o melhor. É apenas o mais popular, devido a ser de fácil utilização.\n");
       printf("O Mac aposta no visual. Mais uma vez, não quer dizer que seja o melhor.\n");
       printf("No Linux e nos outros, temos um SO que aposta na performance, estabilidade, e através de pequenos aditivos, no visual. O único mal que tem é não ser tão acessível a nível de aprendizagem, porque a nível económico... Bem, é grátis.\n");
    	sleep(sleepTime);
       bmp = load_bitmap("Ubuntu.bmp",palette); 
       draw_sprite(screen, bmp, 0, 0); 
    sleep(sleepTime);
    	
       bmp = load_bitmap("XP.bmp", palette); 
       draw_sprite(screen, bmp, 0, 0); 
    sleep(sleepTime);
    	
       bmp = load_bitmap("7.bmp", palette); 
       draw_sprite(screen, bmp, 0, 0); 
    sleep(sleepTime);
       printf("...\n");
       printf("A INTERFACE\n");
       printf("...\n");
       printf("Existem dois tipos de interface: A gráfica e a linha de comandos.\n");
    	sleep(sleepTime);
       bmp = load_bitmap("command.bmp", palette); 
       draw_sprite(screen, bmp, 0, 0); 
    sleep(sleepTime);
       printf("À interface gráfica chama-se GUI (do Inglês Grapical User Interface).\n");
       printf("Aqui podemos explorar um computador com um teclado e um rato, e explora-se facilmente...\n");
       printf("No Windows Vista e 7 temos o Aero, nos outros Windows o ambiente gráfico padrão.\n");
       printf("No Linux, temos vários, como o Gnome, o KDE, BlackBox, XFCE, entre outros...\n");
       printf("Também temos o Compiz, para melhorar o computador visualente, com efeitos como o cubo, janelas gelatinosas...\n");
       printf("...\n");
       printf("Na linha de comandos, apenas vemos um texto simples, num fundo preto. É o clássico.\n");
       printf("Temos vários SOs de linha de comandos, com o MSDOS, o FreeDOS...\n");
       printf("É essencialmente utilizado por programadores, e além de ser único no SO, também pode ser um complemento, como o cmd no Windows ou a consola/terminal no Linux/Unix.\n");
       printf("...\n");
       printf("E esta pequena história da linguagem binária acabou. Espero que tenham gostado.\n");
       printf("X\n");
       printf("...\n");
       printf("FIM\n");
       getchar();
       return 0;
    }
    END_OF_MAIN()

  9. #39
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Well to be anal about it, you are compiling to whats called an ELF my friend
    Executable and Linkable Format - Wikipedia, the free encyclopedia
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  10. #40
    Registered User
    Join Date
    May 2010
    Posts
    30
    Cool.

    Does someone know why my text doesn't display? It's weird. The idea it's to display text and images, in order, like a doc.

    Example:

    [Image]

    Bla bla bla bla....
    Bla bla bla bla...

    [Image]

    Bla bla bla bla...

    But don't know how to do it. It can be a slideshow, like it is now, but I'd like to display the text too, not just the images. What am I doing wrong?

  11. #41
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I would imagine that printf is going to your terminal window, not to the screen that Allegro is drawing. I would also imagine that Allegro has text-drawing functions that you can use.

  12. #42
    Registered User
    Join Date
    May 2010
    Posts
    30
    Yes. It's the textout function. It doesn't work etiher.

    I tried to run with the console, but it does the same. Goes full-screen, and displays the images. Not the text.

  13. #43
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by jpcanaverde View Post
    Yes. It's the textout function. It doesn't work etiher.

    I tried to run with the console, but it does the same. Goes full-screen, and displays the images. Not the text.
    You'll have to make sure that you set up a font, that you pick an (x,y) coordinate that is visible on the screen, that you pick a color that isn't the same as the background, and that you display the bmp to the screen after you've written the text to it.

  14. #44
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by jpcanaverde View Post
    Instead of building an exe, building an sh.

    But text isn't about graphics. Just kidding. Thank's for all.
    Umm, a .sh file is NOT a "linux executable". Generally speaking, executables on linux do not have any suffix at all. Take a look in /usr/bin -- that's all executables, none of them have any suffix.

    A .sh file is not any kind of executable. A .sh file is a SHELL SCRIPT. They are not compiled, and they are not written in C -- they are written (usually) in bash.
    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

  15. #45
    Registered User
    Join Date
    May 2010
    Posts
    30
    Ok, got it. Always learning...

Page 3 of 5 FirstFirst 12345 LastLast
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