Hey there~ I need to write a program to left justify text stored in the link list. Here's part of my program:-
Structure:-
Function:-Code:typedef struct charStruct { char alphabet; struct charStruct* nextChar; } CharacterNode; typedef struct lineHeaderStruct { CharacterNode* firstChar; struct lineHeaderStruct* nextLine; } LineHeaderNode; typedef struct mainHeaderStruct { int fileSize; LineHeaderNode* firstLine; } FileADT;
The output will be weird because it breaks words into parts and store them in the next line but its ok because i want to get this part to work before going any further..So actually this function is incomplete..And i removed the malloc() function from the program to make it shorter and less irritating..I think i'll show you the example of my output..Code:#define LINESIZE 69; void FileFormat(FileADT *fileNode) { LineHeaderNode *newLineNode, *currentLineNode, *nextLineNode; CharacterNode *newCharNode, *currentCharNode, *previousCharNode; int lineLength = 1; currentLineNode = fileNode->firstLine; currentCharNode = fileNode->firstLine->firstChar; while(currentCharNode != NULL) { if(lineLength > LINESIZE) { newCharNode = createNewCharNode('\n'); newLineNode = createNewLineNode(); currentLineNode->nextLine = newLineNode; newLineNode->nextLine = nextLineNode; previousCharNode->nextChar = newCharNode; newLineNode->firstChar = currentCharNode; currentLineNode = newLineNode; nextLineNode = currentLineNode->nextLine; lineLength = 0; } else { if(currentCharNode->alphabet == '\n') { currentLineNode = currentLineNode->nextLine; nextLineNode = currentLineNode->nextLine; currentCharNode = currentLineNode->firstChar; lineLength = 0; } else { previousCharNode = currentCharNode; currentCharNode = currentCharNode->nextChar; } } lineLength++; } } CharacterNode* createNewCharNode(char character) { CharacterNode *newCharNode; newCharNode->alphabet = character; return newCharNode; } LineHeaderNode* createNewLineNode() { LineHeaderNode *newLineNode; return newLineNode; }
Original text
Intended outputCode:Today, computer software is the single most important technology on the world stage. And it is also a prime example of the law of unintended consequences.
Output ReceivedCode:Today, computer software is the single most im portant technology on the world stage. And it is also a prime example of the law of un intended consequences.
Hope you'll be able to help me out here..I'll post my other two functions (adding to link list and display) if you think i should..I've been sitting here for more than 5 hours today and still not able to find whats wrong with it..My butt really hurtsCode:Today, computer software is the single most im portant technology on the world stage. /*This line is missing*/..Help will be greatly appreciated!! Thanks a lot for taking time to read this!!



LinkBack URL
About LinkBacks
..Help will be greatly appreciated!! Thanks a lot for taking time to read this!! 


