[GNHLUG] Silly C/C++ question...
bruce.labitt at autoliv.com
bruce.labitt at autoliv.com
Mon Dec 1 15:30:46 EST 2008
I am sure I will kick myself when I find out the answer, but...
I have a text file that for now consists of 3 lines, later it will have
data.
line 1: integer representing the array size
line 2: four doubles separated by commas
line 3: \n
Here is the code fragment that I have been trying to get to work. I have
no idea why I am getting the output I am.
double fstart1, fend1, , M1, dt1 ; int N;
FILE *fp;
fp = fopen("/home/workspace/input3.txt", "r"); // open input3 file for
reading
printf("input3.txt opened for reading.\n ");
fscanf(fp, "%i", &N); // Find file
length ==> read first line
printf("file length is %i\n", N); // all is good
fscanf(fp, "%d%d%d%d", &fstart1, &fend1, &M1, &dt1); // get fstart,
fend, number of doppler slices & dt
printf(" fstart = %d fend = %d number of doppler slices = %d dt = %d \n",
fstart1, fend1, M1, dt1);
fclose(fp);
The output of the file is:
input3.txt opened for reading.
file length is 1024
fstart = -1706024 fend = -1705632 number of doppler slices = 1049224 dt =
268505456
The values for input3.txt are:
line 1: 1024
line 2: -50e6, 50e6, 256, 5e-10
line 3: \n
Umm, what am I doing wrong?
Thanks,
Bruce
* Please note that the Tyco Electronics Automotive Radar Sensors Group was acquired by Autoliv on September 26th, 2008. My new contact information at Autoliv is included below. Please update your records accordingly.
Bruce Labitt
Autoliv Electronics
1011B Pawtucket Blvd, PO Box 1858
Lowell, MA 01853
Email: bruce.labitt at autoliv.com.
Tel: (978) 674-6526
Fax: (978) 674-6581
******************************
Neither the footer nor anything else in this E-mail is intended to or constitutes an <br>electronic signature and/or legally binding agreement in the absence of an <br>express statement or Autoliv policy and/or procedure to the contrary.<br>This E-mail and any attachments hereto are Autoliv property and may contain legally <br>privileged, confidential and/or proprietary information.<br>The recipient of this E-mail is prohibited from distributing, copying, forwarding or in any way <br>disseminating any material contained within this E-mail without prior written <br>permission from the author. If you receive this E-mail in error, please <br>immediately notify the author and delete this E-mail. Autoliv disclaims all <br>responsibility and liability for the consequences of any person who fails to <br>abide by the terms herein. <br>
******************************
More information about the gnhlug-discuss
mailing list