how do you create a gamelogfile in c using program secure shell
-
creating a battleship game with log in. Need to know how to create a file that will check if login is correct. then be able to fprintf so I can use login file. only need login name not password thanks
-
creating a battleship game with log in. Need to know how to create a file that will check if login is correct. then be able to fprintf so I can use login file. only need login name not password thanks
Are you asking how to write a program from soup to nuts, or are you asking about a specific issue?
The difficult we do right away... ...the impossible takes slightly longer.
-
creating a battleship game with log in. Need to know how to create a file that will check if login is correct. then be able to fprintf so I can use login file. only need login name not password thanks
-
pretty much soup to nut if you wanna put in that inference. I'm new to programming and I cant grasp the concept of either one. Im making a battleship game which calls for a gamelogfile and a gameboard file from which i have to read from. I have to be able to use the gamelogfile to check whether or not the users name is correct. and also for it to be able to store the names of each user.
-
pretty much soup to nut if you wanna put in that inference. I'm new to programming and I cant grasp the concept of either one. Im making a battleship game which calls for a gamelogfile and a gameboard file from which i have to read from. I have to be able to use the gamelogfile to check whether or not the users name is correct. and also for it to be able to store the names of each user.
Member 12084559 wrote:
I'm new to programming and I cant grasp the concept of either one.
Then it is most unlikely that you are going to succeed in creating a battleship game. I suggest your time would be better spent finding some decent books/tutorials etc and working through them in order to build up a reasonable knowledge of the basics.
-
Member 12084559 wrote:
I'm new to programming and I cant grasp the concept of either one.
Then it is most unlikely that you are going to succeed in creating a battleship game. I suggest your time would be better spent finding some decent books/tutorials etc and working through them in order to build up a reasonable knowledge of the basics.
#include #include #include int main (void){ FILE* gamein; int numIn=0; int row=0; int column=0; float Use=0; int gameinput_array[5][5]; //output for(row =0; row<5; row++){ for(column=0; column<5; column++) fscanf(gamein, "%d", &numIn); //have two fscanf's 1st gameinput_array[row][column]=numIn; } // gamein = fopen("gameinput", "r"); while((fscanf(gamein, "%d", &numIn))==1) // 2nd printf("%d", numIn); char gamelog_file[30]; FILE* gamelog; printf("Enter Your User Name here\n"); scanf("%s", &gamelog_file); //gamelog=fopen(gamelog_file,"a");//append return 0; } NOW IM DRAGING BORAD INFO FORM gameinput FILE* WHICH HAS JUST LINES OF 0'S AND 1'S 5*5 GRID NEED TO KNOW ABOUT THE FSCANF'S, WHETHER THEY ARE CORRECT OR NOT WHEN THIS CODE COMPILES I GET SEGMENTATION FAULT BUT IT DOES COMPILE THANKS IF YOU CAN HELP
-
#include #include #include int main (void){ FILE* gamein; int numIn=0; int row=0; int column=0; float Use=0; int gameinput_array[5][5]; //output for(row =0; row<5; row++){ for(column=0; column<5; column++) fscanf(gamein, "%d", &numIn); //have two fscanf's 1st gameinput_array[row][column]=numIn; } // gamein = fopen("gameinput", "r"); while((fscanf(gamein, "%d", &numIn))==1) // 2nd printf("%d", numIn); char gamelog_file[30]; FILE* gamelog; printf("Enter Your User Name here\n"); scanf("%s", &gamelog_file); //gamelog=fopen(gamelog_file,"a");//append return 0; } NOW IM DRAGING BORAD INFO FORM gameinput FILE* WHICH HAS JUST LINES OF 0'S AND 1'S 5*5 GRID NEED TO KNOW ABOUT THE FSCANF'S, WHETHER THEY ARE CORRECT OR NOT WHEN THIS CODE COMPILES I GET SEGMENTATION FAULT BUT IT DOES COMPILE THANKS IF YOU CAN HELP
Member 12084559 wrote:
fscanf(gamein, "%d", &numIn); //have two fscanf's 1st
gamein
has not been assigned to an open file yet. Why?Member 12084559 wrote:
WHEN THIS CODE COMPILES I GET SEGMENTATION FAULT...
Where? Have you stepped through the code (line by line) using the debugger?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Member 12084559 wrote:
fscanf(gamein, "%d", &numIn); //have two fscanf's 1st
gamein
has not been assigned to an open file yet. Why?Member 12084559 wrote:
WHEN THIS CODE COMPILES I GET SEGMENTATION FAULT...
Where? Have you stepped through the code (line by line) using the debugger?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
no I ended up fixing it by moving the two for loops down after the read file. do you know how to call from the gamefile and allow the user to call each coordinate so they can enter each coordinate they choose to try to sink the ship. i Know i have to use if and else statements i just don't know how to integrate them into the file.
-
#include #include #include int main (void){ FILE* gamein; int numIn=0; int row=0; int column=0; float Use=0; int gameinput_array[5][5]; //output for(row =0; row<5; row++){ for(column=0; column<5; column++) fscanf(gamein, "%d", &numIn); //have two fscanf's 1st gameinput_array[row][column]=numIn; } // gamein = fopen("gameinput", "r"); while((fscanf(gamein, "%d", &numIn))==1) // 2nd printf("%d", numIn); char gamelog_file[30]; FILE* gamelog; printf("Enter Your User Name here\n"); scanf("%s", &gamelog_file); //gamelog=fopen(gamelog_file,"a");//append return 0; } NOW IM DRAGING BORAD INFO FORM gameinput FILE* WHICH HAS JUST LINES OF 0'S AND 1'S 5*5 GRID NEED TO KNOW ABOUT THE FSCANF'S, WHETHER THEY ARE CORRECT OR NOT WHEN THIS CODE COMPILES I GET SEGMENTATION FAULT BUT IT DOES COMPILE THANKS IF YOU CAN HELP
I refer you to my previous comment. There is very little loigical structure to your code, and some fairly basic and obvious mistakes. You should write an outline of your program requirements and try to think in terms of using function subroutines for specific tasks, rather than writing everything inline. Only when you have that structure should you start writing the actual code.
-
no I ended up fixing it by moving the two for loops down after the read file. do you know how to call from the gamefile and allow the user to call each coordinate so they can enter each coordinate they choose to try to sink the ship. i Know i have to use if and else statements i just don't know how to integrate them into the file.
Member 12084559 wrote:
i Know i have to use if and else statements i just don't know how to integrate them into the file.
Priceless! You just made my day, sir! Best, John
-- LogWizard - Log Viewing can be a joy!