Below is my current working code, but it is poorly done, and i dont like doing it this way. So i was wondering if its possible to pass through a static string. As when ever I try it just doesn't work! Or able to change a char array.... I tried doing some strcpy but that just was more messy and more work (and didnt quite work)....
char checkint(char printer[])
{
int returner = 0;
do
{
printf("%s",printer[]);
fflush (stdin); /*Clears the keyboard buffer. No special #include needed!*/
scanf("%i", &returner);
}
while (returner == 0);
return returner;
}
int main()
{
int term=0,dobd=0;
char strt[]="How long is the term? ";
term=checkint(strt);
char strt0[]="What day were you born? ";
dobd=checkint(strt0);
return 0;
}
Static String:
int main()
{
int term=0,dobd=0;
term=checkint("How long is the term? ");
dobd=checkint("What day were you born? ");
return 0;
}
Changing char array:
int main()
{
int term=0,dobd=0;
char strt[50]="How long is the term? ";
term=checkint(strt);
strt="What day were you born? ";
dobd=checkint(strt);
return 0;
}
My actual code has allot of questions being asked and allot of data needing to be validated and such. SO having it really nice and clean is how i wanted it..... But my current code is somewhat messy and making allot of variables where there should only be the need for one or even none.
Thanks in advance
Sorry if my post is slightly unclear
This post has been edited by mattisdada: 11 April 2010 - 07:07 PM

New Topic/Question
Reply



MultiQuote





|