943,640 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 482
  • C++ RSS
Nov 13th, 2008
0

Help on begginer project

Expand Post »
Hi guys, right now I am an amateur in the world of programming and am starting to "train" myself by thinking of ideas for a program and figuring out how to write it.

So right now, my first real undertaking I have devised is to write an itemizer where the user can create different categories and place items in each category to keep track of different things.

Here is my code so far which is pretty self explanatory. Not all the cases are filled yet, and int cho is considered the menu option that the user inputs. int cho("choice") =D

consider this thread to be a CVS of sorts =)
c++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <fstream>
  3. #include <windows.h>
  4.  
  5. using namespace std;
  6.  
  7. /*
  8.   Name:
  9.   Copyright:
  10.   Author:
  11.   Date: 12/11/08 19:42
  12.   Description:
  13. */
  14.  
  15.  
  16.  
  17. int main()
  18. {
  19. cout<<"\n\n\n\n";
  20. cout<<"\t1: View Catagory"<<endl;
  21. cout<<"\t2: Append new item"<<endl;
  22. cout<<"\t3: Truncate an item"<<endl;
  23. cout<<"\t4: Create Catagory"<<endl;
  24. cout<<"\t5: Delete Catagory"<<endl;
  25.  
  26. do
  27. {
  28. int cho;
  29. bool repeat(false);
  30. cout<<">>";
  31. cin>>cho;
  32.  
  33.  
  34. switch (cho)
  35. {
  36. case 1:
  37. Clist.open();
  38. cout<<Clist;
  39. cout<<"What catagory would you like to view?";
  40.  
  41. case 2:
  42.  
  43. case 3:
  44.  
  45. case 4:
  46. int name;
  47. cout<<"Title>>";
  48. cin>>name;
  49. ofstream Clist ("Catagorylist.txt", ios::app);
  50. Clist<<name;
  51. Clist.close();
  52. break;
  53.  
  54. case 5:
  55.  
  56. default:
  57. cout<<"Bad user input, please select a menu option";
  58. repeat(true);
  59. }
  60. }
  61. while (repeat);

So I am looking for advice on how to piece this all together. I am not aware of all the techniques and different functions that I can use to accomplish this feat which is why I am looking for guidance and help. Thank you very much in advance for any knowledge or solutions you have to offer me.

If their are any unclear parts of the code please ask me!

Please note that I am trying to keep my code in c++ syntax.
Last edited by clutchkiller; Nov 13th, 2008 at 12:09 am.
Similar Threads
Reputation Points: 23
Solved Threads: 3
Junior Poster
clutchkiller is offline Offline
181 posts
since Jul 2008
Nov 13th, 2008
0

Re: Help on begginer project

bump
Reputation Points: 23
Solved Threads: 3
Junior Poster
clutchkiller is offline Offline
181 posts
since Jul 2008
Nov 13th, 2008
0

Re: Help on begginer project

Where is Clist defined , is it your code ?
Reputation Points: 769
Solved Threads: 128
Banned
ithelp is offline Offline
1,910 posts
since May 2006
Nov 13th, 2008
0

Re: Help on begginer project

What do you really want? How to create Clist? or?
Reputation Points: 110
Solved Threads: 43
Posting Whiz in Training
Sci@phy is offline Offline
279 posts
since Sep 2008
Nov 13th, 2008
0

Re: Help on begginer project

Well im trying to create a clist to write to txt files using the <fstream> header to store peoples categories and items that they decide to create so that they can look them up later or add to them.
Reputation Points: 23
Solved Threads: 3
Junior Poster
clutchkiller is offline Offline
181 posts
since Jul 2008
Nov 13th, 2008
0

Re: Help on begginer project

A few tips:

in case 1:
you're using the variable Clist which isn't declared yet. (you're declaring it in case 4)

This:
C++ Syntax (Toggle Plain Text)
  1. Clist.open();
  2. cout<<Clist;
is not the way to view a text-file. Here's a tutorial.

You should always check if opening your file succeeded, before trying to read or write.

And a few other things, but fix these first.

And now for the most important tip: Bumping threads is very impolite and you're very lucky I'm in such a good mood...
Last edited by Nick Evan; Nov 13th, 2008 at 9:08 am.
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: concurrent access issue
Next Thread in C++ Forum Timeline: Error with getDate function





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC