After I try to implement and understand it, this method sort the value from linked list. Am I right?
I don't need that. I need to compare the array of struct in my node. So in my node which contain...
Type: Posts; User: blueboyz
After I try to implement and understand it, this method sort the value from linked list. Am I right?
I don't need that. I need to compare the array of struct in my node. So in my node which contain...
So do you mean I need to change my whole code to use head from my main? Not from global variables? or I just need to do on this function only?
Am I declaring this insertion sort function right?
I am using source from wikipedia. But it doesn't show anything.
kelas *SortList()
{
/* build up the sorted array from the empty list */
...
If I don't redeclare it, it will shows error and I can't compile it. If I rename it, it will crash when I try to access that function. :S
What compiler do you use? I use codeblock which used gcc I think and DEV C++ it shows no error. If I don't redeclare it in my main my compiler didn't want to compile it.
yes. But actually I just need sorting array of struct in 1 struct at 1 time. Not the entire linked list.
I also tried to change it like this
int sortByName(const void *a,const void *b)
{
...
I don't know how to sort it? Can somebody help me. I am already trying qsort and bubble sort from google but I can't get it works. This is my full code
#include <stdio.h>
#include <stdlib.h>...
How I wanna sorting arra struct inside struct. This is my code. I already changed struct student to array. kelas=node. I want to use qsort but I don't know what to do.
#include <stdio.h>#include...
@claudiu
kelas is my node and mhs is my list. I point *next on my list is because I want to put 2 and more list in 1 node. Thats why I consider to change my list as array. I already making simple...
Well it works. But I got confused when trying to print the node and the student. Basically I want to put some struct student to struct node. But I got realised now struct student and struct node is 2...
Now you know my case. What I mean is like struct node which is linked list with other node contain struct student which is linked list with another student.But now I know I can't limit struct...
OK I got it now.
But what I need is putting 2 or more linked list in 1 node. Maybe I need to change my code and use student as array
Can I used that method to store 2 or more student in 1 node?
With what? Array?
I still can't input anything if I don't use fflush(stdin) before fgets(). Can you help me?
Anyway, why in point 1 I can't cast malloc return? I need to know because my lecture usually declare...
This is my full code. Ignore the munu function for now.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
typedef struct mhs mhs;
Can you explain it more detailed? I bit confused with void *data. With an example of program maybe?
Anyway I managed it somehow to passing data to student and node with allocate length of string....
I am already declare it like subsonics advice. Looks in
mhs mhs
Isn't that what subsonics advice? I use mhs mhs because I already typedef struct mhs to mhs
So i called it as mhs mhs
Well I declare char as pointer in order to make it accept no matter how many the length of the string. Can you help me how to accept any length of string?
Anyway, this is my code. I hope you can fix...
I already tried it
I changed
strcpy(newNode->nama,*nama);
strcpy(newNode->nim,*nim);
to
Is this correct I declare it?
typedef struct mhs mhs;
typedef struct kelas kelas;
struct mhs
{
char *nama;
Then how if I want to add new struct student? If I declare it like that, doesn't it means for making new struct student I need to make new struct node right?
I got confused in my program. I want to make a struct class which is linked list and then inside it I want to have another struct called student. Can I declare struct student as a linked list too?...