On playing around with the code it now seems to make more sense.
for ( l=0; l < na + nb ; l++)
{
A[l] = C[l] ;
printf ( "%d ", A[l] ) ;
}
Type: Posts; User: killpoppop
On playing around with the code it now seems to make more sense.
for ( l=0; l < na + nb ; l++)
{
A[l] = C[l] ;
printf ( "%d ", A[l] ) ;
}
Works perfectly thank you! Just one more little question to do with the print out of A.
Sample Input:
4
3
2
1
Sample Output:
1st Line: 3421 Still dont get...
Ahh yes, makes sense. Thanks =]
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
First of all thanks a lot for the great reply, thought i'd try and tackle it now rather than in the morning! Made all the changers. Points 2 and 3 make perfect sense to me, a little unsure about 1...
Moved straight on to the next sort. Tried to put together a merge sort. Got the merge function working well, but once again its not recursive. So given the input '4' '3' '2' '1'. It splits it in two...
Yep. Nailed it. Thank you so much, can't believe I didn't think of that. Spent ages isolating the problem to those lines! But makes perfect sense, without the return the recursive calls do nothing....
Sorry =]
Right everything goes in fine into the search function. That is the array of numbers, the lowest index of the array '0', the highest index of the array and the value im trying to find in...
Hi people. Been doing some revision for an exam I have in a few months. To get a better idea i've been coding some search and sort algorithms. I have stumbled across a bug with my binary search and...
Yep i got your code just never came across isalpha before, its awesome. I just misread '\'' as " \ " as my text editor puts apostrophe's extremely close together.
Thanks for all the help =]
Thanks a lot laserlight. So if i want to use dynamic memory allocation i do it elsewhere rather than in the read function?
Also could you explain
( isalpha( z ) || z == '-' || z == '\'' )quickly...
Right can you explain this very briefly, i'm new to the language and understand it is an issue with memory. But as far as i can see no word is larger than 30 characters. But i'm obvious not on your...
The Battle of Dien Bien Phu was the climactic battle of the First Indochina War between French Union forces and Viet Minh communist revolutionary forces. The battle occurred between March and May...
#include <stdio.h>
#include<string.h>
#include <stdlib.h>
#include<ctype.h>
char read( FILE *text )
{
int i = 0 ;
char z, *temp ;
temp = calloc( 30, sizeof( char ) ) ;
To laserlight.
So you believe the problem with realloc is that there is a word bigger than 30 in the text document?
Or should i realloc is another location?
And as far as other code there isn't much else that could cause a problem.
I'm currently running it on windows i'll hop over to gdb on ubuntu. All i get while running the program is a pop up that just says 'book.exe has stopped working' .
I get what your saying although hopefully that wont be in the text document =] I just don't quite how i would implement your suggestion. So i would watch the value of i? Once it hits 30 double the...
I get you completely but say if i make temp 50. There won't be any words past that capacity surely?
Also can i take whatever is in the else statement and put it outside with it still being in the...
I tried changing both cases. The first which has (i+1) and the second which has the plus one after.
In reply to your question, there could be a word longer than 30 characters?
MK27 i have tried yours. It compiles fine like the other tries. But once again crashes while its printing out.
I've tried that =[ It causes my program to crash even sooner than before. With just 'i' it manages 100 words of so then crashes. (i+1) it can only do one word.
Although using 'i' would be smart can i just use 1?
char read( FILE *text )
{
int i = 0 ;
char z ;
char *temp ;
temp = calloc( 30, sizeof( char ) ) ;
/* Reads in the words one at a time to an array */
while( ( z = fgetc( text ) ) != EOF...
Um like if i replace 'i' with say 20 it does it fine. Even if i change it to 5 it still takes words bigger than 5 ( does that mean its not working or how realloc works? ) whenever i use 'i' it...
Right i've allocated space in memory for.
temp = calloc( 30, sizeof( char ) ) ;
This array then gets thrown into a list and another word put into it, then into the list etc. What i'm trying...