CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: CList question

  1. #1
    Join Date
    Mar 2010
    Posts
    6

    Question CList question

    Quick question, how do you write the contents of the cell in CList into a file named 'Data'? It's part of an assignment and I am currently stuck on that. Appreciate the help in advance, thanks!

    -Rob

  2. #2
    Join Date
    Mar 2010
    Posts
    6

    Re: CList question

    self bump, really need help with this.. thanks!

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: CList question

    What is CList? Are you sure you need to post in the C# forum?

  4. #4
    Join Date
    Jun 2008
    Posts
    2,477

    Re: CList question

    CList is not a C# class, MFC?

  5. #5
    Join Date
    Mar 2010
    Posts
    6

    Re: CList question

    I'm sorry, I should have elaborated.. CList is supposed to be an array...

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: CList question

    Why would CList be an array? Wouldn't it be called CArray?

    What language are you writing in? C#, C++, other? If C++, are you using MFC?

    Where are you getting CList? Is it part of a library? Are you suppose to write it?

  7. #7
    Join Date
    Mar 2010
    Posts
    6

    Re: CList question

    I didn't write the code, but I am using C#, CList is an array according to an assignment I have to complete.. Hope that clears up any questions... If you have anymore I'll try and answer to the best of my ability..

    The first question in the assignment was "Write the code to create an array named CList consisting of 20 cells. Each cell is capable of storing one character"

    The answer that I had gotten for that was char [] clist = new char [20]

  8. #8
    Join Date
    Mar 2010
    Posts
    6

    Re: CList question

    I feel like I may be getting close:

    while(int variable < clist.length-1) Console.Write clist[int variable];

    maybe?

  9. #9
    Join Date
    Jun 2008
    Posts
    2,477

    Re: CList question

    No, that is an endless loop. You want a basic for or foreach loop:

    Code:
    for( int i = 0; i < clist.Length; ++i )
    {
        Console.WriteLine( clist[i] );
    }
    
    // or...
    
    foreach( char c in clist )
    {
        Console.WriteLine( c );
    }
    As 'clist' is an array and not a list, the name is a bit odd...

  10. #10
    Join Date
    Mar 2010
    Posts
    6

    Re: CList question

    Ah I see, thank you very much.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured