| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need help for a Remarkable functions
So people here is what. I am very very very new to the C/C++ programing language i can barely use printf scanf and very sipmle if else clauses and kind to think of it that is all. I may write stupid things here but I will appriciate any attention you pay to my problem. So I need your help its obvious. The deal is I am studying C/C++ at school but I havent learn anything there the teacher barely shows at class and to tell you the truth I am a STUPID SELF LEARNER. All i know about C++ i know from the help of Microsoft Visual Studio and i teach my self by trial and error. But know I have to write a program for my school i have nobody else to turn to.
What I need to do is a program which can open a user specified text file. Then when it is started the program must read the text file and replace any word in it with a number. Then the number and the word replaced should be entered into a new file which will create something like a dictionary. Then the program should make an output file which will be only from numbers and a dictionary file. After that the program will have to read the numbers file and the dictionary and recreate the original file the user has specified. To tell it short the program must be something like an encryption software which creates a coded file from numbers and a key file - the dictionary. Now i have started to do it but my lack of knowledge is Huge I am posting what i have so far in my fantasy that program should consist of two functions ine encrypting the file and one opposite of the first which will decrypt it later so here is what i have written so far: //Inluding the Header files, which will be needed to run the program #include <stdio.h> #include <stdlib.h> #include <conio.h>//Console input and output //Creating a pointer of type FILE FILE *testdoc; //Main Function of the program void main() { //Declaring a character for the user's choice from the menu int menuchoice=0; //Printing the About Information for the program printf("\n---------------------------------"); printf("\n|<<~Text File Archivator v1.0~>>|"); printf("\n---------------------------------"); //Printing the menu of the program printf("\n 1. New Document"); printf("\n 2. Extract Existing File"); printf("\n 3. Help"); printf("\n 4. About"); printf("\n"); printf("\n Enter your choice:"); //Scanning the choice made by the user scanf("%d", &menuchoice); //An if algorithm for the choices from the menu of the program the user makes //Menu Choice 1: A if for encrypthing a new file if (menuchoice == 1) //Checking if the choice made by the user is 1 { printf("Your Choice Is 1"); //Conformation of the choice made //If for opening a new file if ( (testdoc = fopen( "test document.txt", "r" )) == NULL ) //Checking if the file exists //If the file is == NULL then not opening message is displayed printf( "\nThe file 'Test Document' was not opened\n" ); //Else conformation message is printed to state that the file was opened else printf( "\nThe file 'Test Document' was opened\n" ); } //Else checking if Menu Choice is 2 else if (menuchoice == 2) //If true conformation message is printed { printf("Your Choice Is 2"); } //Else checking if Menu Choice is 3 else if (menuchoice == 3) //If true conformation message is printed { printf("Your Choice Is 3"); } //Else checking if Menu Choice is 4 else if (menuchoice == 34) //If true commands are executed printing an About window in the console { //Writing the respond to the About choice from the user printf("\n---------------------------------"); printf("\n| <<~This is a program for~>> |"); printf("\n|<<~encrypting and decrypting~>>|"); printf("\n| <<~text files using an~>> |"); printf("\n| <<~a dictionary created~>> |"); printf("\n| <<~from the input file~>> |"); printf("\n|<<~which is later needed to~>>|"); printf("\n| <<~read the original file~>> |"); printf("\n---------------------------------"); } //Else checking if any other Menu Choice is made from the user else if (menuchoice > 4 || menuchoice < 1) //If true displaying an error message { printf(" This is not a valid choice!!!"); printf("\n Program Error!!!Please Restart!!!"); } //Waiting for a keybord enter to prevent a display of "Press any key to continue" getch(); } And here i am where from now? any ideas will be good for me but please explain them for an idiot so i can understand them because i dont have much experience with programming thank you for now |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Need help for a Remarkable functions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|