help with my programs please

This is a discussion on help with my programs please within the C Programming forums, part of the General Programming Boards category; i just want to ask if iT is possible that you can have like flashing text or boxes or even ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    13

    can i do this on c ?

    i just want to ask if iT is possible that you can have like flashing text or boxes or even different coloured text ON C. I would also like to know if "\a" the beep is the only noise you can put on a c program OR IS THERE ANY OTHER AUDIO U CAN HAV ON IT THANKS. PLEASE answer me and help me or jus tell me cant if u know thanks
    Last edited by fige18; 10-13-2004 at 12:29 PM. Reason: SPELLIN

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Impress your tutor / instructor / us by:
    1) Writing clean clear code
    2) Using full sentances and words when writing
    3) Don't try to do anything cute, it just gets annoying after awhile
    4) Read all the stickys and Announcements

    Welcome

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    i don't don't have any tips, but i've got a few pointers for you

    *cue drumroll*

    dun-dunt-chhhhh

  4. #4
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    To add to Thantosī lists

    When indenting your code always either use a tab or a certain amount of spaces, dont use spaces and tabs together, since then the indentation can get messed up depending on how the editor of the code interpretes tabs ( that is 1 tab = 2 spaces or 1 tab can be 4 spaces ) ...

    Just a tip though .

    Greets,

    Ganglylamb.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    WELL NOW THAT IT'S BIG AND BLUE I WANT TO HELP FOR SURE

  6. #6
    Registered User
    Join Date
    Oct 2004
    Posts
    13

    ?

    lol ok wots ur problem do u hav any answers or not please

  7. #7
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    With the exception of 5 (whoever was keeping count - what are we up to now?) really low-level mostly-hardware issues, literally anything you've ever seen done on a computer is possible with C. You want to look for APIs that handle sound and console I/O. You can probably find some small ones out there. SDL is a full-blown graphics, sound, etc... API made for C, which can really give your program some great functionality, but just google around. The standard functions don't allow you to do this (I don't think...)

  8. #8
    Banned
    Join Date
    Aug 2004
    Posts
    128
    everything is possible.

  9. #9
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    Honestly i dont think your lecturer will find it okay when she/ he has to proofread like 200 of those programs and then find something where she will have to look for the lines of code that actually have some functionality and which was the initial assignment.

    Lecturers might be cruel on you but pls dont be cruel on them.

    PS: dont even know if that was gramatically correct...

  10. #10
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    ^^^^ yea, in my intro to programming class i actually got points deducted for using a loop before they were taught to us.....

    if you must insist, i believe some of the functions you need reside in conio.h, but i can't remember that well...and if that's correct, then i also believe that it's not a very portable header so there's a chance it might not run on different computers

  11. #11
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Last edited by fige18 : Today at 10:29 AM. Reason: SPELLIN
    This made me laugh.

  12. #12
    Registered User
    Join Date
    Oct 2004
    Posts
    13
    does anyone actually have a headerfile and a command i could try to get a noise or flashin text etc coloured text cheers

  13. #13
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    hehehe
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  14. #14
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    since you insisted

    Code:
    #define ON (1)
    #define OFF (0)
    
    void ChangeSpeaker( int status ) {
    
    	int portval;
    	portval = inport( 0x61 );
    	if( status == ON ){
    		portval |= 0x03;
    		}
    	else{
    		portval &=~ 0x03;
    		}
    	outportb (0x61, portval );
    	}
    
    void Sound( int hertz ){
    	unsigned divisor = 11931180L / hertz;
    
    	ChangeSpeaker( ON );
    
    	outportb( 0x043, 0xB6 );
    	outportb( 0x42, divisor & 0xff );
    	outportb( 0x42, divisor >> 8 );
    	}
    void NoSound(void){
    	ChangeSpeaker( OFF );
    	}
    do not forget to include dos.h
    ....
    boy your lecturer will be happy when the program hangs at a constant 5000 Hertz note ( that is if the program hangs before NoSound () is called ) is a pleasant thing to hear.

    This code should be working ( i just googled and copied and pasted it here but i guess it should work )

    ::edited:
    dead link
    ::edit 2::
    so now when you want a nice clear sound of the middle ages just put this in your code
    Code:
    ChangeSpeaker (ON);
    Sound(5000);    //note with a frequencie of  5000 hertz
    NoSound();
    AND OMG it is a portable something so no matter what compiler your lecturer uses he will always have nice note,
    of course you can now make nice songs,
    OR if you want to take up another challenge read in all the notes from a file and then play the corresponding frequencies...

    ::edit 3::
    Alright this is the last time i edit my post and i hope you will be satisfied with the answer and let this post have a peacefull death.

    Straight out of my compilerīs help stuff
    Syntax

    #include <conio.h>
    void textcolor(int newcolor);

    Description

    Selects new character color in text mode.

    Note: Do not use this function for Win32s or Win32 GUI applications.

    textcolor selects the foreground character color. This function works for the console output functions. newcolor selects the new foreground color. You can set newcolor to an integer as given in the table below, or to one of the symbolic constants defined in conio.h. If you use symbolic constants, you must include conio.h.
    Once you have called textcolor, all subsequent functions using direct video output (such as cprintf) will use newcolor. textcolor does not affect any characters currently onscreen.
    The following table lists the allowable colors (as symbolic constants) and their numeric values:

    Symbolic constant Numeric value

    BLACK 0
    BLUE 1
    GREEN 2
    CYAN 3
    RED 4
    MAGENTA 5
    BROWN 6
    LIGHTGRAY 7
    DARKGRAY 8
    LIGHTBLUE 9
    LIGHTGREEN 10
    LIGHTCYAN 11
    LIGHTRED 12
    LIGHTMAGENTA 13
    YELLOW 14
    WHITE 15
    BLINK 128

    You can make the characters blink by adding 128 to the foreground color. The predefined constant BLINK exists for this purpose.
    For example:

    textcolor(CYAN + BLINK);

    Note: Some monitors do not recognize the intensity signal used to create the eight "light" colors (8-15). On such monitors, the light colors are displayed as their "dark" equivalents (0-7). Also, systems that do not display in color can treat these numbers as shades of one color, special patterns, or special attributes (such as underlined, bold, italics, and so on). Exactly what you'll see on such systems depends on your hardware.

    Return Value

    None.
    EXAMPLE from Borland compiler help file
    Code:
    #include <conio.h>
    
    int main(void)
    {
       int i, j;
    
       clrscr();
       for (i=0; i<9; i++)
       {
           for (j=0; j<80; j++)
              cprintf("C");
           cprintf("\r\n");
           textcolor(i+1);
           textbackground(i);
       }
    
       return 0;
    }
    Watch out this code is Nonportable

    Here you go enjoy the nice things that is if you are using Borland compiler, this code will probably not compile under any other compiler.
    Last edited by GanglyLamb; 10-13-2004 at 04:21 PM.

  15. #15
    Registered User
    Join Date
    Oct 2004
    Posts
    13
    misplaced u sed somet bout usin conio.h wot for exacly a sound or flashin or coloured text? do u know how to do it? cheers

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recommend upgrade path for C programs
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-22-2007, 07:32 AM
  2. Reroute where programs write to
    By willc0de4food in forum C Programming
    Replies: 7
    Last Post: 09-21-2005, 05:48 PM
  3. Problem using java programs within C code
    By lemania in forum Linux Programming
    Replies: 1
    Last Post: 05-08-2005, 03:02 AM
  4. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 05:42 AM
  5. executing c++ programs on the web
    By gulti01 in forum C++ Programming
    Replies: 4
    Last Post: 08-12-2002, 04:12 AM

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