I have ****ty turbo c and its not a great help any feedback would be most appreciated
I have ****ty turbo c and its not a great help any feedback would be most appreciated
Cheers
Bazza
I the code is small, try pasting only the relevant code instead of uploading the whole file. You'll get faster and usefull tips from people around here.
Ok cheers
TC really sux
#include <stdio.h>
void lines_rev(void);
void chars_rev(void);
void num_chars(void);
void num_words(void);
void num_lines(void);
void main(void)
{
int choice = 0;
while ((choice = main_menu())!=6)
{
switch (choice)
{
case 1:num_lines();break;
case 2:num_words();break;
case 3:num_chars();break;
case 4:chars_rev();break;
case 5:lines_rev();break;
case 6: exit(1);
defaultrintf("invalid selection!\n\n");break;
}
}
system ("cls");
printf("\n\n\n\n\n\n\n\n\t\t ** WELCOME TO THE TEXT FILE ANALYSER **");
printf("\n\n\n\n\n\n\n\nt\t Please press any key to continue");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n SHAUN BARRY 00121738");
getch();
system ("cls");
printf("\n\n\n\t\t\t MAIN MENU\n\n");
printf("\t\t 1. Count number of lines in file\n");
printf("\t\t 2. Count number of words in file\n");
printf("\t\t 3. Count number of characters in file\n");
printf("\t\t 4. Display file in reverse character order\n");
printf("\t\t 5. Display file in reverse line order\n");
printf("\t\t 6. Exit \n");
Printf("\n\n\t\t Please enter a choice between 1 - 6 :");
scanf("%d", &choice);
getch();
}
void num_lines(void)
{
printf("lines");
getchar();
}
void num_words(void)
{
printf("words");
getchar();
}
void num_chars(void)
{
printf("chars");
getchar();
}
void chars_rev(void)
{
printf("chars rev");
getchar();
}
void lines_rev(void);
{
printf("lines rev");
getchar();
}
}
Cheers
Bazza
1.) Use the [CODE] [/ CODE] tags whenever you paste some code.
2.) What problem are you facing with this code?
3.) Where is the body of main_menu()?
It will not even compile, because there's an extra } bracket at the end.
As you can guess im a bit of noob the problem I am having with this code is for the menu to activate the sub sections of code
Thankyou for your interest
Cheers
Bazza
getchar() returns the ASCII value of a character read from the stdin. The ASCII values of 1, 2, 3, ... are 49, 50, 51, ... respectively. So, you can go about with two ways:
1.) In 'switch(choice) - case' statements, place the numbers in single quotes:
2.) Switch on ASCII values returned by getchar():Code:switch (choice) { case '1':num_lines();break; case '2':num_words();break; ...
Code:case 49: /* '1' */ num_lines(); break; case 50: /* '2' */ num_words(); break; ...
> Printf("
No - printf
> void main(void)
int main(void)
As for your problem, it's really simple (and it's definitely not your compiler - the tool's as useful as the person using it). Think about what you're doing. You have your code to handle input for the menus, and THEN you print the menu out? Try again.
-Govtcheez
[email protected]
Cracked the menu bit now the hard bit the actual function the menu was for thanks for your help guys really appreciated
Cheers
Bazza