Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how do you create a gamelogfile in c using program secure shell

how do you create a gamelogfile in c using program secure shell

Scheduled Pinned Locked Moved C / C++ / MFC
game-devlinuxtutorial
10 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 12051105
    wrote on last edited by
    #1

    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

    Richard Andrew x64R L 2 Replies Last reply
    0
    • U User 12051105

      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

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • U User 12051105

        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

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        See https://msdn.microsoft.com/en-gb/library/windows/desktop/aa363874(v=vs.85).aspx[^].

        U 1 Reply Last reply
        0
        • L Lost User

          See https://msdn.microsoft.com/en-gb/library/windows/desktop/aa363874(v=vs.85).aspx[^].

          U Offline
          U Offline
          User 12051105
          wrote on last edited by
          #4

          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.

          L 1 Reply Last reply
          0
          • U User 12051105

            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.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            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.

            U 1 Reply Last reply
            0
            • L Lost 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.

              U Offline
              U Offline
              User 12051105
              wrote on last edited by
              #6

              #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

              D L 2 Replies Last reply
              0
              • U User 12051105

                #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

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                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

                U 1 Reply Last reply
                0
                • D David Crow

                  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

                  U Offline
                  U Offline
                  User 12051105
                  wrote on last edited by
                  #8

                  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.

                  J 1 Reply Last reply
                  0
                  • U User 12051105

                    #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

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0
                    • U User 12051105

                      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.

                      J Offline
                      J Offline
                      John Torjo
                      wrote on last edited by
                      #10

                      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!

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups