Tuesday, July 14, 2009

I have problem in programming! pls answer this..It is .c file extension?

how do I make a program that never goes down even if i press enter? it will remain only on the same line.


EXAMPLE of my program:


#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


int main()


{


int major,minor,line,line1,units,sUnit;


float grades,wpa,msca,grade1,sum,average,avera...


char another='Y';


printf("Press Enter to Start...\2\n");


scanf("%c",%26amp;another);


system ("cls");


printf("\nHow many major subjects you have: ");


scanf("%d",%26amp;major);


printf("Supply equivalent grade and unit for the major subjects:\n\n");


printf(" GRADES UNITS\n");/* after I key in the grade it must not go down


even if I press ENTER, it must be in the same line*/


for(line=1; line%26lt;=major;line++)


{


printf("(%d) Major subjects:\t ",line);


scanf("%f",%26amp;grades);


printf("\t");


scanf("%d",%26amp;units);


}


getch();


return 0;


}








\\try to paste this on your program.

I have problem in programming! pls answer this..It is .c file extension?
the line will move down because of "echo" on the terminal





best way is to output ANSI terminal escape codes to move the cursor back up to the previous line





for reference:





ESC = ASCII#(27)





printf("\033[1A") moves the cursor up a line on most termninals


No comments:

Post a Comment