Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Jan 2001 11:18:49 +0000
From:      Joao Fernandes <root@OpsyDopsy.net.dhis.org>
To:        questions@freebsd.org
Subject:   C++ Coding logical error...
Message-ID:  <01010111272200.01898@OpsyDopsy.net.dhis.org>

next in thread | raw e-mail | index | archive | help
Hi there. Im not on the questions list, so, if you wish to reply to me, please
do so at root@opsydopsy.net.dhis.org.

My problem is as follows: I have a string of text data, char *rawdata, and I
wanted to 'format' it in an array, char *data[]. One line on each array 'space'.

I've tryed this a lot of diferent ways, with no success... Maybe a more
experienced programmer may enlighten me.

The function I have for formating the data is as follows:
----------------------------------------------------
int filec::format_data()
{
	unsigned int i=0, number_of_characters=0;
	char *line=NULL;

	for (i=0; i<strlen(rawdata); i++) {
		if (rawdata[i]=='\n')
		{
			++number_of_characters;
			
			line=(char *)calloc(sizeof (char *), number_of_characters);
			data[numberoflines]=strdup(line);

			line=NULL;
			++numberoflines;
		}
		
		++number_of_characters;
	}

	return OK;
}
-----------------------------------------------------

Error:
-----------------------------------------------------
Jan  1 11:17:59 OpsyDopsy /kernel: pid 1897 (main), uid 0: exited on signal 11 (core dumped)
Segmentation fault (core dumped)
-----------------------------------------------------


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?01010111272200.01898>