-
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???
-
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");
}
-
thats what u get when u get a newbie trying to do programming :rolleyes:
thanks a lot:)
-
Hey we all start some where. I have made the same mistakes ;)
-
1 Attachment(s)
since we such great friends all of a sudden :eek:
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??
-
What is locate macro supposed to do? Print to a cetian location on the screen?
-
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)");
-
Why dont you use printf?
Like:
printf("\t\t\tData Entry Screen\n");
printf(First Name:\n");
-
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
-
OH GREAT I AM DOING YOUR HOMEWORK.....JK :p
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.
-
dont worry dude i got like 2 more if i ever get this working right :D
ya he told us to use a locate macro which just puts them to like different row and cloumn
-
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 ;)
-
well it works with gotoxy(y,x)