HELP with C, I am losing it fast.... 
Author Message
 HELP with C, I am losing it fast....

|> Any help would be appreciated.  I am soooo frustrated.  I actually yelled
|> my 2 year old son yeaterday when he interupted me while I was working on

Helping save your sanity seems impossible. Posting a request for help with
such little details as there was is already insane.

Post some example code illustrating the problem you are having. The
guidelines for posting state that you should post a _short_ complete
compilable and executable piece of code stating clearly what you expected it
to do (and presumably it is not doing).

A lot of valuable information is available in the FAQ list available by
anonymous ftp from


Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
Others see <gopher://>,
< http://www.*-*-*.com/ ;or<
internetwork-mail-guide>. -- < http://www.*-*-*.com/ ;
fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]

Sat, 30 May 1998 03:00:00 GMT  
 HELP with C, I am losing it fast....
|> Okay,
|> I am stumped.  
|> I have a file of archaeology sites.  I need to do a
|> search on them using their site id number.

The bsearch() function seems natural for this.

|> Once I get their number I want to display the file.
|> For example the file (arch) looks like this:
|> 1234
|> 42.75
|> Seasonal Use Site
|> 0987
|>  2.34
|> Long Term Use Site
|> 5555
|> 89.00
|> Short Term Use Site
|> The fields are site id#, percentage of acreage, and site type.
|> (the fields are much more numerous but I figure if I get the
|> process down, I can figure out the rest.
|> I want to use C to do this in (It will need to be used accross many
|> platforms)  I am not a C guru.

A guru is hardly necessary ;-). I've been using C for almost 5 years, but
will probably not consider myself a guru even after using it for 50 years.

|> I want to do a search on th id number I enter in on the screen.
|> When it is found I want to display all the field names on the
|> screen.  The second field is floating integer.  I will want
|> to do calculations on the acreage so it needs to be a floating
|> integer.  When the calculations are done I want to save the file
|> (with any new changes) to its original name.

A floating integer? I assuming you mean a floating point number in general.

|> I have tried doing this using 'struct' but can't seem to get the integer
|> values to print to the screen or out.  (They read in okay.  I have yet to
|> figure out how to make calculations (addition and subtraction mostly)
|> on the floating variables.)

That's strange! You seem to *know* they read in ok, but can't print them
out. Is this an assumption or have you verified in some other fashion,
i.e. de{*filter*}, that the data is truly in memory?

|> Any help would be appreciated.  I am soooo frustrated.  I actually yelled at
|> my 2 year old son yeaterday when he interupted me while I was working on
|> this.

I'd be most inclined to ask you to post the smallest ANSI C subset of your
problem to the newsgroup that demonstrates your problem. You say you
used 'struct' but did not supply the actual declarations used. Here's
the way I'd do it.

1) Create an array (probably dynamically) with number of elements equal to
   the number of elements in the file.
2) Open the file for reading and read each element into the array from the
3) Close the file.
4) Sort the array based on the id field.          (qsort)

  5) Get id's as input and search for it's index. (bsearch)
  6) Display the structure.
  7) Make whatever changes you desire.
Until no more changes are desired

8) Open the file for writing and write each element from the array to the file.
9) Close the file.
"If it wasn't for C, we would be using BASI, PASAL, and OBOL."

Sat, 30 May 1998 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. I am new to programming and am lost

2. I am totally lost today?

3. I am totally lost today?

4. Newbie: separate big .cs file into small .cs files

5. newbe/cs student, need help w/ code

6. Compiler error CS 1595 - Help

7. Help!!! Novice CS Advice

8. Losing focus LOSES BTN_CLICKED events!

9. Lost Data Exchange Control->Now losing sanity :-)

10. faster strcat (and/or faster string append in C++)

11. faster,faster

12. Faster faster


Powered by phpBB® Forum Software