473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Leave Blank spaces in Array using fscanf C

4
Hi, I want to copy a csv file into an array using fscanf and keep the blank spaces in the csv file rather than just skip over them to the next number.

there are too many spaces in the csv file to fill them all in manually

I'm using C

any clues how i could do this??

thanks, heres a sample of my code

double ReadFromFile(FILE *inFile)
{
double value;

fscanf(inFile,"%lf,", &value);

printf("the value=%lf\n", value);

return (value);
}
Aug 7 '08 #1
2 4505
Try using a loop, and whenever the loop goes through an iteration you add a space at the next available location in the array. This isn't perfect as it doesn't differentiate between spaces and say a new line character but it should get you closer to what you want.

On another note, it would help a lot if you used code tags around your code. It makes it much more readable.

Edward
Aug 7 '08 #2
weaknessforcats
9,208 Expert Mod 8TB
The whole point of fscanf is to skip whitespace. All of the scanf()-like funcitons assume you know in the inout form,at ahead of time. Otherwise, you wouldn't be able to code all that %c%d stuff.

If you don't know the input format, then don't a scanf()-like function. Instread, use a function that reads byte by byte so you can look at each byte an decide what to do with it.
Aug 8 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Ruben | last post by:
Hello. I am trying to read a small text file using the readline statement. I can only read the first 2 records from the file. It stops at the blank lines or at lines with only spaces. I have a...
4
by: John Bullock | last post by:
Hello, I am at wit's end with an array sorting problem. I have a simple table-sorting function which must, at times, sort on columns that include entries with nothing but a space (@nbsp;). I...
29
by: yourmycaffiene | last post by:
Okay, this if my first post so go easy on me plus I've only been using C for a couple of weeks. I'm working on a program currently that requires me to read data from a .dat file into a 2d array and...
11
by: skumar434 | last post by:
Hi everybody, I am faceing problem while assigning the memory dynamically to a array of structures . Suppose I have a structure typedef struct hom_id{ int32_t nod_de; int32_t hom_id;
3
by: totoro2468 | last post by:
Hi, I'm a complete NOOB. How do I get fscanf to copy into an array? I also need to use malloc, but where do I put it in my file? _______________________________________________________ FILE...
10
by: padh.ayo | last post by:
Hi, I have a array structure called people It is properly initialized to 100 array structure elements. Now, I'm reading in from the command line a txt file, and I get them to open correctly. In...
9
by: kvnsmnsn | last post by:
Over the course of my career I've transitioned from an Ada programmer (am I dating myself?) to a C programmer to a Java programmer and now back to a C programmer with the job I've currently...
27
by: aravind | last post by:
Hi, I need to develop a menu system for a project of mine. The menu will be displayed on a character LCD display driven by ARM7 Microcontroller. For this purpose i wish to construct a structure in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.