Re: A Question about arrays file merging

From: Anthony Borla (ajborla_at_bigpond.com)
Date: 11/28/04


Date: Sun, 28 Nov 2004 22:07:05 GMT


"K. Mark Northrup" <renman82964@msn.com> wrote in message
news:1101671826.828675@utility.isomedia.com...
> Greetings Group,
>
> I'm new here and am learning C/C++ for my new job;
> I do have some programing experience-mostly working
> with databases.
>

See my recent post entitled:

   [OT] Learning to Program ...

C is not C++, and C++ is a multi-facted language, one that is not all that
easy to learn.
You may need to carefully assess your current skills, clarify your goals,
and devise an appropriate C++ learning strategy based on these.

>
> I am working with two different types of binary files,
> the first one contains binary data that represents lat/long
> data in the form of doubles and I have a console program
> that converts the binary data to doubles and prints the data
> to the screen.
>
> The thing I need to do now is to place the data into a 2 by
> 'N' array (because each pair of lat/long data represents a
> single pixel that in turn, represents a point on the earth's surface).
>

Are you saying you have in your possession an exectable file [but not the
source code] that reads a binary formated file, appropriately converts and
prints the data to the standard output stream, and that you wish to know
how:

* Run this executable file, say from another C or C++
   program ?

* To replicate this functionality in a C or C++ program ?

and in both cases load the output into an array [or some other container] ?

Since you already have an exectable program, why not just run it, redirect
its output to a file, and have your new program read this new file into the
array / container ? This could be done from the command-line:

    execProg > datafile.txt

If you'd like a 'cleaner' solution, the same could be performed from within
a C or C++ program via the 'system' function. Of course if you know the data
format you can use either language's I/O facilities [e.g. 'fopen', 'fread'
functions etc] to directly read in, and load the data.

You may want to consider whether an alternative to a native array may not be
more appropriate. Certainly in both languages you have both compile-time and
run-time arrays [i.e. created via dynamically allocated memory based on
run-time size information]. In C++ you also have various container class
[e.g. vector] as a standard offering that may be of use. It may even be that
you don't need to load all data into memory to perform required procesing ?

>
> The second binary file contains the color/grayscale info for
> each pixel (I need to confirm which). The program already
> exists in a Linux C format and I am attempting to convert it to
> a Windows format while maintaining as much code 'portability'
> as possible.
>

I'm not entirely sure what you mean. If this is a data conversion issue I
don't see that portabilitiy would be an issue.

UNIX-based C programs are, generally speaking, surprisingly portable
[excludes, of course, GUI-based programs, and those making system calls etc
(bypassing the standard library calls), and those making use of specialist /
proprietary libraries]. Often all you need is a suitable compiler, and a
preparedness to make minor code tweaks.

Thus, if the program is GCC-compilable, obtaining the MinGW compiler [and
other support libraries] may be all that is needed to see that program work
in the Win32 environment. Alternatives include installation of a UNIX
emulation layer, the CygWin product, being a prominent example, to provide
the environment [including system call emulation] that some programs may be
expecting.

On the other hand if you are seeking to replicate a GUI-based / graphics
program, then I understand the portability concern.

>
> Any help, thoughts, or suggestions would be most welcome.
>

I've always found that first designing a language-independant solution using
concepts with which one is most familiar, to be a great help in clarifying
ideas, and providing a framework around which to organise further work.

I hope this helps.

Anthony Borla



Relevant Pages

  • Re: 9bit arithmetics in C
    ... If his computer is big endian then he will not have to change anything. ... Lets also assume the simulation requores that these ... the native format and the one which converts from the native format to ... emulation of the simulated hardware and of the about portability of the ...
    (comp.lang.c)
  • Re: Raw image in header file
    ... Such things don't belong in headers. ... initialiser for an array. ... Or, you could use a file format that, itself, is C code. ... Here is the complete contents of an .xpm file, ...
    (comp.lang.c)
  • Re: opening multiple files in fortran
    ... last format: r_hifreq10000.out ... array, outnu. ... - so each of my 10,000 output files would have 14,391 entries apiece). ... you are truly reading a large number of files, ...
    (comp.lang.fortran)
  • Re: How do I use the unpack function?
    ... I'm getting streaming tile data from a renderer in order to allow the user to see the rendering of tiles in real-time to create the total image. ... The data is raw bytes and can be any format. ... All data is a string of bytes, and interpreting that string of bytes to have some particular form is applying a format to it. ... Here's a hint on how to use numpy for decoding a byte string into an array of floats. ...
    (comp.lang.python)
  • Re: textread and strread questions
    ... The type of each return argument from textread is given by the FORMAT ... Looks like your data is a array of cell. ... "Requires string or character array input.". ...
    (comp.soft-sys.matlab)

Quantcast