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. Hi! Im new at coding and i wanted to ask some help.

Hi! Im new at coding and i wanted to ask some help.

Scheduled Pinned Locked Moved C / C++ / MFC
sharepointhelp
4 Posts 4 Posters 4 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.
  • P Offline
    P Offline
    panda08
    wrote on last edited by
    #1

    The incomplete code bellow doesnt seem to be working as intended. I would be really gratefull to any help. #include #include #include using namespace std; const int N=20;

    const char Filename[]= "Shiplist.dat"; struct Ship { unsigned int number; float capacity; char name[50]; }; fstream sp; int menu() { int choice; cout << "\n \t MENU"; cout << "\n 1. Add individual ships"; cout << "\n 2. Add a list of ships"; cout << "\n 3. Print the list of all ships on screen"; cout << "\n 4. Show the ships with the biggest load capacity "; cout << "\n 5. Search ship by name"; cout << "\n 6. Add shipments"; cout << "\n 7. Cancel shipments"; cout << "\n 8. Save ship information"; cout << "\n 9. Add new ship to the list"; cout << "\n 10. Exit"; do { cout << "\n Your choice:"; cin >> choice; } while (choice<1 || choice>10); return choice; } Ship input () { Ship S= { 0 }; cin.ignore(); cout << "\n Enter ship number:"; cin >> S.number; cin.ignore(); cout << "\n Enter the name of the ship:"; cin.getline(S.name,50); cout << "\n Enter the load capacity of the ship:"; cin >> S.capacity; return (S); } int enter (Ship Lib[], int n) { int i, m; do { cout << "\n Enter information for how many ships(max 5 in one go):"; cin >> m; } while(m<0 || m>5); if (n+m < 20) { for (i= n; i

    Greg UtasG L D 3 Replies Last reply
    0
    • P panda08

      The incomplete code bellow doesnt seem to be working as intended. I would be really gratefull to any help. #include #include #include using namespace std; const int N=20;

      const char Filename[]= "Shiplist.dat"; struct Ship { unsigned int number; float capacity; char name[50]; }; fstream sp; int menu() { int choice; cout << "\n \t MENU"; cout << "\n 1. Add individual ships"; cout << "\n 2. Add a list of ships"; cout << "\n 3. Print the list of all ships on screen"; cout << "\n 4. Show the ships with the biggest load capacity "; cout << "\n 5. Search ship by name"; cout << "\n 6. Add shipments"; cout << "\n 7. Cancel shipments"; cout << "\n 8. Save ship information"; cout << "\n 9. Add new ship to the list"; cout << "\n 10. Exit"; do { cout << "\n Your choice:"; cin >> choice; } while (choice<1 || choice>10); return choice; } Ship input () { Ship S= { 0 }; cin.ignore(); cout << "\n Enter ship number:"; cin >> S.number; cin.ignore(); cout << "\n Enter the name of the ship:"; cin.getline(S.name,50); cout << "\n Enter the load capacity of the ship:"; cin >> S.capacity; return (S); } int enter (Ship Lib[], int n) { int i, m; do { cout << "\n Enter information for how many ships(max 5 in one go):"; cin >> m; } while(m<0 || m>5); if (n+m < 20) { for (i= n; i

      Greg UtasG Offline
      Greg UtasG Offline
      Greg Utas
      wrote on last edited by
      #2

      This kind of thing is usually posted as a question. On the menu bar just under the site banner, click on quick answers/Ask a Question. However, "doesn't seem to be working as intended" tells us nothing about what your code is trying to do, and no one is going to waste time trying to guess. You have to provide more details if you want an answer.

      Robust Services Core | Software Techniques for Lemmings | Articles
      The fox knows many things, but the hedgehog knows one big thing.

      <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
      <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

      1 Reply Last reply
      0
      • P panda08

        The incomplete code bellow doesnt seem to be working as intended. I would be really gratefull to any help. #include #include #include using namespace std; const int N=20;

        const char Filename[]= "Shiplist.dat"; struct Ship { unsigned int number; float capacity; char name[50]; }; fstream sp; int menu() { int choice; cout << "\n \t MENU"; cout << "\n 1. Add individual ships"; cout << "\n 2. Add a list of ships"; cout << "\n 3. Print the list of all ships on screen"; cout << "\n 4. Show the ships with the biggest load capacity "; cout << "\n 5. Search ship by name"; cout << "\n 6. Add shipments"; cout << "\n 7. Cancel shipments"; cout << "\n 8. Save ship information"; cout << "\n 9. Add new ship to the list"; cout << "\n 10. Exit"; do { cout << "\n Your choice:"; cin >> choice; } while (choice<1 || choice>10); return choice; } Ship input () { Ship S= { 0 }; cin.ignore(); cout << "\n Enter ship number:"; cin >> S.number; cin.ignore(); cout << "\n Enter the name of the ship:"; cin.getline(S.name,50); cout << "\n Enter the load capacity of the ship:"; cin >> S.capacity; return (S); } int enter (Ship Lib[], int n) { int i, m; do { cout << "\n Enter information for how many ships(max 5 in one go):"; cin >> m; } while(m<0 || m>5); if (n+m < 20) { for (i= n; i

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

        Ship input () {
        Ship S= { 0 };
        cin.ignore();
        cout << "\n Enter ship number:"; cin >> S.number;
        cin.ignore();
        cout << "\n Enter the name of the ship:"; cin.getline(S.name,50);
        cout << "\n Enter the load capacity of the ship:"; cin >> S.capacity;

        return (S);
        

        }

        It will help get a quicker answer if your code is properly indented, and uses the correct <pre> tags as above.

        1 Reply Last reply
        0
        • P panda08

          The incomplete code bellow doesnt seem to be working as intended. I would be really gratefull to any help. #include #include #include using namespace std; const int N=20;

          const char Filename[]= "Shiplist.dat"; struct Ship { unsigned int number; float capacity; char name[50]; }; fstream sp; int menu() { int choice; cout << "\n \t MENU"; cout << "\n 1. Add individual ships"; cout << "\n 2. Add a list of ships"; cout << "\n 3. Print the list of all ships on screen"; cout << "\n 4. Show the ships with the biggest load capacity "; cout << "\n 5. Search ship by name"; cout << "\n 6. Add shipments"; cout << "\n 7. Cancel shipments"; cout << "\n 8. Save ship information"; cout << "\n 9. Add new ship to the list"; cout << "\n 10. Exit"; do { cout << "\n Your choice:"; cin >> choice; } while (choice<1 || choice>10); return choice; } Ship input () { Ship S= { 0 }; cin.ignore(); cout << "\n Enter ship number:"; cin >> S.number; cin.ignore(); cout << "\n Enter the name of the ship:"; cin.getline(S.name,50); cout << "\n Enter the load capacity of the ship:"; cin >> S.capacity; return (S); } int enter (Ship Lib[], int n) { int i, m; do { cout << "\n Enter information for how many ships(max 5 in one go):"; cin >> m; } while(m<0 || m>5); if (n+m < 20) { for (i= n; i

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

          panda08 wrote:

          The incomplete code bellow....

          If you completed, would it then work?

          panda08 wrote:

          The incomplete code bellow doesnt seem to be working...

          Was it intentional that you failed to explain what it is (not) supposed to do?

          panda08 wrote:

          ...as intended.

          What is its intent? The onus is on you to pare down your code to just that which is problematic; not ours to wade through a bunch of code to try and figure out what it is supposed to do and why it is not doing such.

          "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

          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