Results 1 to 7 of 7

Thread: C++ noob here

  1. #1
    Senior Member
    Join Date
    Jul 2003
    Posts
    1,457
    Thanks
    0
    Thanked
    0 times in 0 posts

    Question C++ noob here

    I just be a idiot, cause i just cant see why this C++ isn't working, well, it is working, but the cin.get() doesn't seem to hold the code when it ends like it should.

    HERES THE FILE

    and heres the code:

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    
      char string;
      int Z = 0;
    
      cout<<"Enter a String: ";
      cin>> string;
      cin.ignore();
      "\n\n\n\n";
    
      for(int x = 0; x < 10; x++) {
            
            for(int y = 0; y < Z; y++) {
                    cout<<" ";
                    }
                    
            cout<< string << "\n";
            z++;
            }
            "\n";
    
      cin.get();
    }
    If anyone can explain why it doesn't keep the window open after the program has finished, i'd be very grateful

    Ben

  2. #2
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Because all operations are complete when it's finished. The same thing happens in most languages, you need to stall the window. At the end put system("pause");

  3. #3
    Senior Member
    Join Date
    Jul 2003
    Posts
    1,457
    Thanks
    0
    Thanked
    0 times in 0 posts
    Well its suddenly decided to start working....very strange

  4. #4
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    With or without the command?

  5. #5
    Senior Member
    Join Date
    Jul 2003
    Posts
    1,457
    Thanks
    0
    Thanked
    0 times in 0 posts
    without, cin.get() is supposed to make it pause, and its randomly started working

  6. #6
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Might not have compiled it before last making changes perhaps?

  7. #7
    Sam
    Sam is offline
    Registered+
    Join Date
    Oct 2003
    Posts
    22
    Thanks
    0
    Thanked
    0 times in 0 posts
    cin would only make it pause while it waited for input. Maybe you supplied input previously unknowlingly.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. is it just me or is it cause am a noob
    By b!lly in forum HEXUS Suggestions
    Replies: 3
    Last Post: 22-03-2005, 02:27 PM
  2. Network noob needs advice...
    By wellmad in forum Networking and Broadband
    Replies: 0
    Last Post: 20-03-2005, 08:55 AM
  3. Noob LOMAC piccies
    By Skeps in forum PC
    Replies: 1
    Last Post: 01-02-2004, 01:43 PM
  4. Linux Noob Q
    By daveham in forum Software
    Replies: 5
    Last Post: 02-10-2003, 09:37 AM
  5. noob Q: OC P4C - how hard is it really?
    By shredisn@tdead in forum PC Hardware and Components
    Replies: 58
    Last Post: 20-08-2003, 10:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •