Results 1 to 13 of 13

Thread: what am i doing wrong?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Location
    in a little closet
    Posts
    30

    what am i doing wrong?

    i wrote this in C

    ---------------------------------------
    #include <stdio.h>

    void printtoscreen();
    void printtoprinter();

    void main()
    {
    printtoscreen();
    printtoprinter();
    }

    void printtoscreen();
    {
    fprintf(stdout,"This goes to the screen");
    }

    void printtoprinter();
    {
    FILE *stream;
    stream = fopen("LPT1","w");
    fprintf(stream,"This goes to the printer");
    }
    --------------------------
    --------------------------
    i get this error

    program.cpp(17,2): declaration terminated incorrectly
    program.cpp(22,2): declaration terminated incorrectly
    --------------------------
    what did i do wrong to those 2 declarations???
    All Help Very Much Appreciated

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Code:
    #include <stdio.h> 
    
    void printtoscreen(); 
    void printtoprinter(); 
    
    void main() 
    { 
    printtoscreen(); 
    printtoprinter(); 
    } 
    
    void printtoscreen()   //<--------- No ;
    { 
    fprintf(stdout,"This goes to the screen"); 
    } 
    
    void printtoprinter()  //<--------- No ;
    { 
    FILE *stream; 
    stream = fopen("LPT1","w"); 
    fprintf(stream,"This goes to the printer"); 
    }
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Location
    in a little closet
    Posts
    30
    thats what u get when u get a newbie trying to do programming

    thanks a lot
    All Help Very Much Appreciated

  4. #4
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Hey we all start some where. I have made the same mistakes
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Location
    in a little closet
    Posts
    30
    since we such great friends all of a sudden
    maybe you can tell me whats wrong with this one, yes i know it has a lot of mistakes but for this code

    -------------------------------------------------
    #include <stdio.h>

    #define Locate(r,c) printf("\033[%d;dH",r,c)
    #define PAUSE; Locate(47,3); printf("Press Any Key To Continue"); getchar()

    void printscreen();
    void getdata();
    void printreport();

    char firstname[8],lastname[11],street[15],state[3],insurancecomp[15];
    int zipcode,homenumber,worknumber,policynum;

    void main()
    {
    printscreen();
    getdata();
    printreport();
    }

    void printscreen()
    {
    Locate(2,3);puts("\t\t Data Entry Screen");
    fprintf(stdout,"");
    Locate(5,3);puts("First Name:");
    Locate(10,3);puts("Last Name:");
    Locate(15,3);puts("Street:");
    Locate(20,3);puts("State:");
    Locate(25,3);puts("Zip Code");
    Locate(30,3);puts("Home Phone");
    Locate(35,3);puts("Work Phone");
    Locate(40,3);puts("Insurance Company");
    Locate(45,3);puts("Policy Number");
    }

    void getdata()
    {
    Locate(5,9);gets(firstname);
    Locate(10,9);gets(lastname);
    Locate(15,9);gets(street);
    Locate(20,9);gets(state);
    Locate(25,9);scanf("%i",&zipcode);
    Locate(30,9);scanf("%i",homenumber);
    Locate(35,9);scanf("%i",worknumber);
    Locate(40,9);gets(insurancecomp);
    Locate(45,9);scanf("%i",policynum);
    PAUSE;
    }

    void printreport()
    {
    FILE *stream;
    stream = fopen("LPT1","w");
    fprintf(stream,"\f\t\t Request Patient Information\n\r");
    fprintf(stream,"\t First Name\n\r");
    fprintf(stream,"\t Last Name\n\r");
    fprintf(stream,"\t Street\n\r");
    fprintf(stream,"\t State\n\r");
    fprintf(stream,"\t Zip Code\n\r");
    fprintf(stream,"\t Home Phone\n\r");
    fprintf(stream,"\t Work Phone\n\r");
    fprintf(stream,"\t Insurance Company\n\r");
    fprintf(stream,"\t Policy Number\n\r");
    }
    ----------------------------------
    ----------------------------------

    i got it to run after fixing a few bugs, and yes its still not complete but why in the hell am i getting stuff like this in DOS when i run it

    -----------------------------------------
    whats with all the:
    [2
    [5
    [10 etc..

    i mean i know they in the locate definition but what i setup wrong for them to show up??
    Attached Images Attached Images  
    All Help Very Much Appreciated

  6. #6
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    What is locate macro supposed to do? Print to a cetian location on the screen?
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  7. #7

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Location
    in a little closet
    Posts
    30
    yes it is man, did i set it up wrong???

    oh **** i just remembered how to skip a link which i wanted to do. you cant do what i did here ah?

    --------------------
    Locate(2,3);puts("\t\t Data Entry Screen");
    fprintf(stdout,"");
    Locate(5,3);puts("First Name:");
    ----------------------------

    just put \n\n or so in back of the Data Entry Screen(insert here)");
    Last edited by Newer_Newbie; Mar 31st, 2003 at 03:14 PM.
    All Help Very Much Appreciated

  8. #8
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Why dont you use printf?
    Like:
    printf("\t\t\tData Entry Screen\n");
    printf(First Name:\n");
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  9. #9

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Location
    in a little closet
    Posts
    30
    cuz im doing this for a homework assingment and he wanted us to use the LOCATE macro which i want to beat the **** out of the guy already for teaching C instead of going to C++ since its like you know better now.

    is there a way to use the macro or should i just do it like you stated??

    using Borland 5.0.2 by the way
    All Help Very Much Appreciated

  10. #10
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    OH GREAT I AM DOING YOUR HOMEWORK.....JK

    Well I dont understand what the locate macro is SUPPOSED to do but thats why you are getting crap on the screen. Did he give you that or did you make that up.

    Learning C is a good way to start. Its what I did. It is still used ALOT. There is nothing wrong with it at all.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  11. #11

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Location
    in a little closet
    Posts
    30
    dont worry dude i got like 2 more if i ever get this working right

    ya he told us to use a locate macro which just puts them to like different row and cloumn
    All Help Very Much Appreciated

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Old post, I know, but I'm just catching up with the posts.

    If you're running this within a windows DOS box, those don't know the placing escape sequences. You need a real DOS for that.
    You ought to tell your teacher that
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Location
    in a little closet
    Posts
    30
    well it works with gotoxy(y,x)
    All Help Very Much Appreciated

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width