Welcome, Guest. Please login or register.

Author Topic: Learning C with the Amiga  (Read 32639 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Learning C with the Amiga
« Reply #149 from previous page: February 13, 2007, 09:00:14 AM »
@Cymric

I've had to do a lot of text parsing too and even then I rarely needed to concatenate strings. There are usually solutions you can come up with that don't require endless reallocation and strcat ;-)
int p; // A
 

Offline falemagn

  • Sr. Member
  • ****
  • Join Date: May 2002
  • Posts: 269
    • Show only replies by falemagn
    • http://www.aros.org/
Re: Learning C with the Amiga
« Reply #150 on: February 13, 2007, 09:26:00 AM »
@ Cymric

Why would a text parser need to concatenate strings?
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Learning C with the Amiga
« Reply #151 on: February 13, 2007, 10:17:20 AM »
Quote

falemagn wrote:
@ Cymric

Why would a text parser need to concatenate strings?


My point exactly. All the parsing I've done, if anything usually involved breaking text up into smaller tokens, not concatenating them into larger ones.
int p; // A
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #152 on: February 13, 2007, 01:31:11 PM »
Quote

Karlos wrote:
Quote

falemagn wrote:
@ Cymric

Why would a text parser need to concatenate strings?


My point exactly. All the parsing I've done, if anything usually involved breaking text up into smaller tokens, not concatenating them into larger ones.


So you've never built SQL statements on the fly based on parameters in a filtering selection screen for a program that generates a report?
 

Offline falemagn

  • Sr. Member
  • ****
  • Join Date: May 2002
  • Posts: 269
    • Show only replies by falemagn
    • http://www.aros.org/
Re: Learning C with the Amiga
« Reply #153 on: February 13, 2007, 01:39:46 PM »
Quote

lou_dias wrote:

So you've never built SQL statements on the fly based on parameters in a filtering selection screen for a program that generates a report?


And that's text parsing exactly in which way?

On the costructive side: yes, in those cases - which however have nothing to do with parsing, the standard C library string functions are a pain to use. However, you can use whichever string library suits you best, or even not use C but rather C++.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Learning C with the Amiga
« Reply #154 on: February 13, 2007, 02:07:40 PM »
Precisely.

That's not parsing text, that's building text. String concatenation may be a viable option there, but even then there are other solutions.

Most database stuff I've had to do that wasn't from a basic LAMP/ASP perspective has all been in C++ anyway and there the basic string class has proved more than adequate for said purposes.
int p; // A
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #155 on: February 13, 2007, 04:34:32 PM »
Ok, I've written code that parses a file and replaces one text/byte(s) code with another.  Now in VB6, you can read a 2MB file into a string, in memory, and doing a simple replace all at once and then writing over the old file was much faster than the traditional line by line method of drilling through the file, while writing to another followed by the delete of the old one and rename of the new to match the old.

It came in handy when converting large .CSV files with lines terminated with CR to CR/LF and vice versa.

File access is slow compared to memory access, hence having the entire file in memory was ideal and VB's "Replace" command allows you to use any sequence of bytes.  It's not just limited to 7 bit ascii.

This turned a batch processing job of many large files into one that went from taking over an hour to taking just several minutes.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Learning C with the Amiga
« Reply #156 on: February 13, 2007, 04:43:43 PM »
@lou_dias

#include

More search/match/replace power than you can throw a very large stick at ;-)
int p; // A
 

Offline amipal

  • Jr. Member
  • **
  • Join Date: Oct 2003
  • Posts: 71
  • Country: gb
    • Show only replies by amipal
    • Flickr
Re: Learning C with the Amiga
« Reply #157 on: February 13, 2007, 05:52:02 PM »
@adz

Quote
The C Programming Language (ANSI C) - B.W. Kernighan & D.M. Ritchie

I've been recommended this book also, so I picked up a copy from eBay - much better than the "C for Dummies" book I used initially. However, I haven't looked at it  since this time last year!

Time to get back into it methinks... :crazy:  ;-)
After a decade away from the scene, I am back!
 

Offline voxel

  • Sr. Member
  • ****
  • Join Date: Feb 2002
  • Posts: 322
    • Show only replies by voxel
Re: Learning C with the Amiga
« Reply #158 on: February 13, 2007, 06:46:43 PM »
@ mel_zoom :-)

Hi :-)

There is a good list where you can ask for advice in learning C, that is open to all be they beginners or pros :-), and is sp*mfree, I'm it's moderator in chief ;-)

This list count some of the best Amiga coders and they will be happy to help you, so why not apply to it?

You can go there : Amiga-C2 mailling list and push the "join" button :-)

Amigalement,
Jean-François Bachelet, Amiga nuts since 1985.
-------------------------------------------------
Welcome to Happy Computing : Amiga! (© 2K4-2K8 voxel)
 

Offline CannonFodder

  • Hero Member
  • *****
  • Join Date: Sep 2003
  • Posts: 1115
    • Show only replies by CannonFodder
Re: Learning C with the Amiga
« Reply #159 on: February 13, 2007, 08:51:37 PM »
Quote

lou_dias wrote:
Ok, I've written code that parses a file and replaces one text/byte(s) code with another.  Now in VB6, you can read a 2MB file into a string, in memory, and doing a simple replace all at once and then writing over the old file was much faster than the traditional line by line method of drilling through the file, while writing to another followed by the delete of the old one and rename of the new to match the old.

It came in handy when converting large .CSV files with lines terminated with CR to CR/LF and vice versa.

File access is slow compared to memory access, hence having the entire file in memory was ideal and VB's "Replace" command allows you to use any sequence of bytes.  It's not just limited to 7 bit ascii.

This turned a batch processing job of many large files into one that went from taking over an hour to taking just several minutes.


Why use VB to do the job of PL/SQL(T-SQL etc)?

Anyway, isn't this thread supposed to be about learning C?  What point are you trying to achieve by spamming it with off topic crap about how superior VB is?

Start another thread and discuss it there.
People are hostile to what they do not understand - Imam Ali ibn Abi Talib(AS)
 

Offline mel_zoomTopic starter

  • Full Member
  • ***
  • Join Date: Jan 2007
  • Posts: 231
    • Show only replies by mel_zoom
Re: Learning C with the Amiga
« Reply #160 on: February 13, 2007, 09:16:30 PM »
cannonfodder:

Perhaps he is trying to tempt me into VB coding :-)
I love my MX5!
Please pay a visit
 

Offline CannonFodder

  • Hero Member
  • *****
  • Join Date: Sep 2003
  • Posts: 1115
    • Show only replies by CannonFodder
Re: Learning C with the Amiga
« Reply #161 on: February 13, 2007, 09:27:28 PM »
Quote

mel_zoom wrote:
cannonfodder:

Perhaps he is trying to tempt me into VB coding :-)


Well if we are all playing that game.  Learn PL/SQL, you'll get paid more. ;-)
People are hostile to what they do not understand - Imam Ali ibn Abi Talib(AS)
 

Offline mel_zoomTopic starter

  • Full Member
  • ***
  • Join Date: Jan 2007
  • Posts: 231
    • Show only replies by mel_zoom
Re: Learning C with the Amiga
« Reply #162 on: February 13, 2007, 09:31:14 PM »
Nobody seems to get this. Im learning for my own interests, to be better qualified to deal with some of the technical jibber jabber I come across in my work and most of all - for fun!

A lot of SQL is used where I currently work - several implementations used across a range of systems. The one thing they all have in common is that they are overwhelmingly boring!
I love my MX5!
Please pay a visit
 

Offline CannonFodder

  • Hero Member
  • *****
  • Join Date: Sep 2003
  • Posts: 1115
    • Show only replies by CannonFodder
Re: Learning C with the Amiga
« Reply #163 on: February 13, 2007, 09:34:57 PM »
Quote

mel_zoom wrote:
Nobody seems to get this. Im learning for my own interests, to be better qualified to deal with some of the technical jibber jabber I come across in my work and most of all - for fun!

A lot of SQL is used where I currently work - several implementations used across a range of systems. The one thing they all have in common is that they are overwhelmingly boring!


Shall I start another thread?

"Why PL/SQL is not boring" ;-)
People are hostile to what they do not understand - Imam Ali ibn Abi Talib(AS)
 

Offline mel_zoomTopic starter

  • Full Member
  • ***
  • Join Date: Jan 2007
  • Posts: 231
    • Show only replies by mel_zoom
Re: Learning C with the Amiga
« Reply #164 on: February 13, 2007, 09:37:40 PM »
If you must. I am thinking I will have to start a new thread if I want to ask questions about C coding. This one seems to have gone off all by itself :lol:
I love my MX5!
Please pay a visit