473,379 Members | 1,220 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,379 software developers and data experts.

fwrite

Hi,
I'm using bulk write using the fwrite function and i'm writting the charachter array. i am getting some unwanted spaces written in the output. my output is variable length. how to elimate the spaces thru fwrite function. My array widht is 4000 and lenght is 50000.

asciiz is a charachter array of lenght 4000

asciiz data_to_write[50000];

fwrite(data_to_write,sizeof(asciiz),50000,datFile) ;

Thanks in advance,
Abu
Dec 4 '07 #1
3 1432
weaknessforcats
9,208 Expert Mod 8TB
asciiz is a charachter array of lenght 4000

asciiz data_to_write[50000];
Please show me the definition of the asciiz type. What you arw showing here won't compile.
Dec 4 '07 #2
Please show me the definition of the asciiz type. What you arw showing here won't compile.
struct {
char name[4000];
}asciiz;
Dec 5 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
You could just declare an array:
Expand|Select|Wrap|Line Numbers
  1. char data_to_write[50000][4000];
  2.  
Anyhow, the fwrite will write the entire 200MB in one swatch. If you have spaces or variable length output, then you need to calculate the amount of data to be written after eliminating the spaces.

This will be a very time consuming process.

Also, if the output is variable kength, how would you know how much to read back in?? Otherwise, your disc file will become a black hole.
Dec 5 '07 #4

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

Similar topics

3
by: Antoine Bloncourt | last post by:
Hello everybody Sorry to bother you but I have a problem writing datas into a file ... I want to make a backup of my MySQL database and put the result into a ..sql file. To do this, I use...
23
by: FrancisC | last post by:
how to use fwrite( ) instead of fprintf( ) in this case? I want to generate binary file. FILE *fnew; int i, intName; double array; fprintf(fnew, "%d\n", intName);...
17
by: SW1 | last post by:
I wrote a small program which does something like tftp - transfering files and some chat, anyway i got a problem with fwrite, here is a snippet of my code: while(length > 0) { putchar('.');...
15
by: Suraj Kurapati | last post by:
Hello, I'm having a rather strange bug with this code: for certain values of 'buf', a segmentation fault occurs when 'free(buf)' is followed by an 'fwrite()'. In the program output, there is no...
4
by: ibrahimover | last post by:
typedef struct{ char name; int no; }TAM; typedef struct{ char name; char ch; }HARF;
3
by: sumit1680 | last post by:
Hi everyone, I am using the below listed code The code is #include<stdio.h> #include<stdlib.h> #include<string.h>
2
by: Richard Hsu | last post by:
// code #include "stdio.h" int status(FILE * f) { printf("ftell:%d, feof:%s\n", ftell(f), feof(f) != 0 ? "true" : "false"); } int case1() { FILE * f = fopen("c:\\blah", "wb+"); int i = 5;
10
by: Sheldon | last post by:
Hi, I am trying to learn C from scratch and, though I do know how to program in Python, many things in C are hard to understand - even after reading the examples. I guess because so many...
12
by: hemant.gaur | last post by:
I have an application which writes huge number of bytes into the binary files which is just some marshalled data. int len = Data.size(); //arrary size for (int i = 0; i < len; ++i)...
25
by: Abubakar | last post by:
Hi, recently some C programmer told me that using fwrite/fopen functions are not efficient because the output that they do to the file is actually buffered and gets late in writing. Is that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.