Re: A Question about arrays file merging
From: Anthony Borla (ajborla_at_bigpond.com)
Date: 11/28/04
- Next message: Anthony Borla: "Re: A little disappointed"
- Previous message: Paulie: "[C] #define - unexpected Results"
- In reply to: K. Mark Northrup: "A Question about arrays file merging"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Anthony Borla: "Re: A little disappointed"
- Previous message: Paulie: "[C] #define - unexpected Results"
- In reply to: K. Mark Northrup: "A Question about arrays file merging"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|