User Profile

Collapse

Profile Sidebar

Collapse
raindeer
raindeer
Last Activity: Aug 23 '07, 01:32 PM
Joined: Mar 19 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • raindeer
    replied to handling input and output data in files
    in C
    Thank you for your advice!

    Bigturtle, the idea is indeed to have a rather big input file in the end, so I need to know which numbers represent which parameters.
    Any function of the program will scan the parameters in the input file and store the values that it needs in local variables.
    I have read the man files on strcmp (or strncmp) and this is what I have. It compiles but gives segment violation when running. I suppose...
    See more | Go to post

    Leave a comment:


  • raindeer
    replied to handling input and output data in files
    in C
    Thank you for your help!

    I now use getline to read in every line one by one. But how do I evaluate the value of the first part of the line? For instance, if the first part is "Temperatur e", how do I put the second part of the line (the actual numerical value of the parameter) in a variable "B".

    Code:
    double B;
    char xxx[100];
    variable[99] = '\0'; 
    /* or just assign xxx[100] =
    ...
    See more | Go to post
    Last edited by AdrianH; May 9 '07, 03:48 PM. Reason: Please use [code][/code] tags for greater readability.

    Leave a comment:


  • raindeer
    started a topic handling input and output data in files
    in C

    handling input and output data in files

    Hello,

    I want to create an input file for my program in which I store all of my input data (constants etc.).
    Something of this kind:

    ------------
    Input parameters
    ------------

    boxlengthX 1.0
    boxlengthY 1.0
    boxlengthZ 1.0
    radius (nm) 10
    Temperature (K) 298
    etc.


    which scan function...
    See more | Go to post

  • raindeer
    replied to getline and C
    in C
    Thank you for your comment!

    I did what you indicated, replacing the getline function using scanf as a test.
    Now it sometimes skips lines in the middle of the input file as well, even though they all contain 12 variables. However, the last line is only evaluated once.
    The input file is actually the result of an other program that puts these 12 variables on a line, followed in the end by \n, so I guess there should be no...
    See more | Go to post

    Leave a comment:


  • raindeer
    started a topic getline and C
    in C

    getline and C

    Hello,

    I am new at computer programming and I am having trouble using getline() in C.
    I use an input file that contains 12 variables on every line.
    From the printf statements below, I notice that scanf, although risky, does the job correctly.

    However, getline skips the first line from the input file and evaluates the last line twice.
    Do you have any idea what I am doing wrong?

    Thank...
    See more | Go to post

  • raindeer
    started a topic struct and C
    in C

    struct and C

    Hello,

    I am completely new to computer programming and I have trouble using structures in a correct way in a C program.

    After testing several components of the program, the problem is basically this:

    #include <stdio.h>

    main()
    {
    /*define structure with containing three coordinates*/
    struct point {
    float x;
    float y;
    float z;
    };...
    See more | Go to post
No activity results to display
Show More
Working...