Thread: files in C Help !!

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    8

    Unhappy files in C Help !!

    I need to form a file at C:\\ and record 10 numbers for two variable in this file.The numbers will be entered BY user. How do i do it ?

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    How do you do what? Get the numbers from the user? Create the file? Write to the file? Count to 10?

    Show us your work and tell us exactly where you're stuck. Then we'll help you out.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User AtomRiot's Avatar
    Join Date
    Jan 2003
    Posts
    120
    Code:
    http://www.google.com/search?num=100&hl=en&newwindow=1&safe=active&q=c+file+io+tutorial&btnG=Search
    All Your Base Are Still Belong to Someone!!!
    And you Remember that!!!

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Code:
    #include <stdio.h>
    
    int main(void)
    {
    	/* Start here */
    
    	return 0;
    }
    That's your starting point. From there, break your problem down to very small components.

    Can you read a number from a user? Can you use an array? Can you open and read/write to a file? If you can do all of these, great. If not, then get your textbook out and start studying those parts. Write functions to do simple aspects of the program. Put it together, and you're set.

    BTW, your questions are way too vague. Ask questions that pertain to details. A very broad "how-do-I" question will get a very broad answer.

  5. #5
    Registered User
    Join Date
    May 2007
    Posts
    8
    There will be two variable,named A and B.For each one of these variable, there will be ‘n’ item observation number and asked observation assets.The numbers will be registered in C:// and they will be read from here. Ok ?

  6. #6
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210


    OK, so what work did you do on it already?

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by leminGracy View Post
    There will be two variable,named A and B.For each one of these variable, there will be ‘n’ item observation number and asked observation assets.The numbers will be registered in C:// and they will be read from here. Ok ?
    No, it's not Ok.

    So far, you haven't put forth a single line of code - not one. I believe you should do a little bit more than nothing, on this program.

    You'll need to break out your book, your tutorial, your class notes, or even google; but you need to get involved with writing this code.

    We are here to help - but not here to do all for you.

  8. #8
    Registered User
    Join Date
    May 2007
    Posts
    8
    ok ok , allright then,How can I order all columns in matrix one By one ? ?

  9. #9
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Another broad question. Here's a random broad answer that might or might not apply:

    Use fprintf().

  10. #10
    Registered User
    Join Date
    May 2007
    Posts
    8
    Thank You for your help,but I have already know it.If you have any other thing that u can suggest me I will be happy. example matrix 2x2 , How can I order all columns in this matrix one By one

  11. #11
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by leminGracy View Post
    Thank You for your help,but I have already know it.If you have any other thing that u can suggest me I will be happy. example matrix 2x2 , How can I order all columns in this matrix one By one
    Normally, when you traverse a 2X2 matrix, you might do so in a row by row fashion. That is, row 0, col 0, then row 0, col 1, etc.

    Which would be like this in code:
    Code:
    for (row = 0; row < MaxRows; row++)
       for (col = 0; col < MaxCols; col++)
           printf("\n row: %d,   column: %d ", row, col);
    
    To traverse a column, just swap the variables:
    
    for (col = 0; col < MaxCols; col++)
       for (row = 0; row < MaxRows; row++)
           printf("\n column: %d,   row: %d ", col, row);
    Now you'll get col 0, row 0, then col 0, row 1, etc.

    Hope that helps.

  12. #12
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Perhaps a bit of research is in order? This is not the place to have your homework done for you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ressources files
    By mikahell in forum Windows Programming
    Replies: 4
    Last Post: 06-19-2006, 06:50 AM
  2. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 03:28 AM
  3. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  4. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  5. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM