AlexKonsta
New Coder
Fill in the code as before, so that for each letter of the name is printed its distance from the
his next appearance or 0, as follows:
hello
h: 0
e: 0
l: 1
l: 0
o: 0
CODE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct charact {
typedef struct charact Char;
typedef Char * ListofChar;
typedef Char * CharNode_ptr;
void letters(char name[50], ListofChar * chars_ptr);
void report(ListofChar chars);
Char * createnode(char ch);
int main(void) {
Char * createnode(char ch) {
void letters(char name[50], ListofChar * lst_ptr) {
void report(ListofChar chars) {
his next appearance or 0, as follows:
hello
h: 0
e: 0
l: 1
l: 0
o: 0
CODE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct charact {
char ch;
int occurs;
struct charact *next;
};typedef struct charact Char;
typedef Char * ListofChar;
typedef Char * CharNode_ptr;
void letters(char name[50], ListofChar * chars_ptr);
void report(ListofChar chars);
Char * createnode(char ch);
int main(void) {
char name[50];
ListofChar chars = NULL;
scanf("%49s", name);
letters(name, &chars);
report(chars);
return 0;
} Char * createnode(char ch) {
CharNode_ptr newnode_ptr ;
newnode_ptr = malloc(sizeof (Char));
newnode_ptr -> ch = ch;
newnode_ptr -> occurs = 0;
newnode_ptr -> next = NULL;
return newnode_ptr;
} void letters(char name[50], ListofChar * lst_ptr) {
/* add your code */
return;
} void report(ListofChar chars) {
/* add your code */
return;
}