Hi guest! As you can see, the new Wizard Forums has been revived, and we are glad to have you visiting our site! However, it would be really helpful, both to you and us, if you registered on our website! Registering allows you to see all posts, and make posts yourself, which would be great if you could share your knowledge and opinions with us! You could also make posts to ask questions!
Hi all, the question is on I/O. Although File IO is used, there will still be printed messages such as a motivational string and help number.
The question is those rolling message LED displays, would I need to write an interface header file for dealing with that, or would it itself as the display just display the printed output?
Not sure how those things work.
/*
Three files exist.
Runners.dat
Returns.dat
Missing.dat
Runners - runaways data file which has names unsorted
Returns - runaways that have returned home sorted
Missing - those runaways that have not returned.
Statistics get pulled, and updated, if there is a return its name is wiped from the runners file.
For each runner, we do a bunch of stuff and then print motivational string, hotline string, and then restarts.
*/
The question is here, if I need to do anything special for rolling LED text displays.
Oh... Well, if you write it in something like Arduino C, then there is nothing else you need to do, as Arduino does contain interfaces for those scrolling displays. If this is a pure C, check whether the manufacturer of the display supplies any kind of library. Else you would have to write an interface that turns the text into the pin input on the display. Or, if you got one of those modern wi-fi ones, they usually also contain some form of REST service or other kinds of interfaces you can call from there with the help of the libcurl.
Okay, runaways are focal point of attention this month. So I pick back up on C/C++ programming and use a hash table to sort them I guess, or base characteristics and a linked list or tree in that case. Want clean code, working code, code that has a reasonable runtime analysis. Three files -...
wizardforums.com
Post automatically merged:
Still working on this. Working on this because a missing kid poster I saw one day, the next day the fourteen year old was found dead in the university athletic field here.
Post automatically merged:
Current code (still needs lots of work):
#include <stdio.h>
#include <stdlib.h>
#inlcude <math.h>
#include <ctype.h>
#include <string.h>
/* Pre-processor directives and includes */
/*
Purpose: This program reads two files, runaways and motivational/HelpNumbers.
The goal is to return the runaways to a SAFE environment.
Once a runaway is found, flags are updated to signal to update the returns file,
and unlink the runaway node and insert into the return list.
At that point the flags are read everything updated.
There is an interface engineers will have to create and implement.
*/
/* Abstract Data Type structure definitions */
/* Runner data and stats ADT using runners.dat file */
typedef struct Runner {
char* runner_name[40];
char* runner_age[3];
char* runner_gender[2];
char* runner_contact[20];
} runner;
/* Returns data and stats ADT using returns.dat file */
typedef struct Returns {
char* returns_name[40];
char* returns_age[3];
char* returns_gender[2];
char* returns_contact[20];
} returns;
/* Motivational messages ADT using motivation.txt file */
typedef struct Motivational
{
/* To comply with characters display size for LED text scroll devices */
char* Intro_String[40];
char* Core_Motivational_String[40];
char* List_Help_Num_String[40];
} motivational;
/* SAFE houses and mental health and DPS numbers ADT using SAFE.dat file */
typedef struct SAFENumbers {
char* SAFE_address[40];
char* SAFE_state[3];
char* SAFE_zipcode[6];
char* SAFE_contact[20];
} safenumbers;
/* FOR ENGINEERS TO IMPLEMENT -- interface for LED text scrolling devices */
typedef struct LED_Device_Interface { } LEDDevInterface;
typdef struct Histogram { } histogram;
typedef struct Statistics { } statistics;
typedef struct Set_ADT {
/*
Items are inserted and deleted, there is no inherent order in the
items in a given set. Merge_set, however does a merge-sort on the
items in the given set(s). Before any call is made to a set operation,
The set has been declared and a constructor has been applied.
The '==' and '<<' operators apply to values of ItemType.
} set_adt;
typedef struct set_adt set;
typedef struct List
{
}list_adt;
typedef struct list_adt list;
Returns="ReturnsData.txt"
OFile="RandRStatResults.txt"
Runner runaway_list(list L);
list L, runaway_list, return_list, safe_list;
set S, S1, S2, MergedSet, joinedSet;
int numSetItems;
/* Function Prototypes */
Void setMakeEmpty(set S);
boolean setIsEmpty(set S);
boolean setIsFull(set S);
int setCardinality(set S);
int setUnion(set S1,S2);
int setIntersection(set S1, S2);
int setDifference(set S1,S2);
set setStore(set S; int item);
int setDeleteItem(set S, int item);
set setCreate(set S);
set setJoin (set S, S1, S2, joinedSet);
set setMerge(set S1, S2, mergedSet);
set setPrintSet (set S);
int setDestroy(set S);
FILE* chomp_file(&filename, &mode, 256);
FILE* slurp_file(&filename, &mode, 4196);
returns runawayfound();
runner runawayreturn();
void motivational();
void` helpresources();
list return_list():
list setItem_to_Node();
void print_stats(void);
void print_histogram(returns R1, runners R2, histogram H){ }
/* Function Implementation */
set setCreate(set S) {
/* Purpose: to create a new set of runners, returns, and other structures as */
/* well as flags to signal to the reader to be updated in terms of statistics, */
int setUnion(set S1,S2)
{
result.maxItems=MAX_SET_ITEMS;
for (i=0;i < MAX_SET_ITEMS-1;i++)
{
result.items=items || S2.items;
}
/S1=result; return S1;/
return result;
}
int setIntersection(set S1, S2)
{
result.maxItems=MAX_SET_ITEMS;
for (i=0;i < MAX_SET_ITEMS-1;i++)
{
result.items=items && setB.items;
}
return result;
}
int setDifference(set S2)
{
result.maxItems=MAX_SET_ITEMS;
for (i=0;i < MAX_SET_ITEMS-1;i++)
{
result.items=items && setB.items;
}
return result;
}
set setStore(set S; int item)
{
}
int setDeleteItem(set S, int item)
{
}
set setJoin (set S, S1, S2, joinedSet)
{
/* Purpose: to create a new set of runners, returns, and other structures as */
/* well as flags to signal to the reader to be updated in terms of statistics, */
}
set setMerge(set S1, S2, mergedSet)
{
/* Purpose: to create a new set of runners, returns, and other structures as */
/* well as flags to signal to the reader to be updated in terms of statistics, */
}
set setPrintSet (set S) { ; }
{
/* Purpose: to print exact set pointed to. */
}
int setDestroy(set S)
{
/* Purpose: to destroy exact set pointed to, then deallocate memory and return */
/* the deallocated memory back to the heap to avoid memory leaks, free pointers */
/* to avoid dangling pointer/null pointer errors. */
}
FILE* chomp_file(&filename, &mode, 256);
{
/* Purpose: to split the current exact file pointed to that has read mode enabled, */
/* and returns the exact field values specified. */
}
FILE* slurp_file(&filename, &mode, 4196);
{
/* Purpose: to read the current exact file pointed to that has read mode enabled */
/* all at once. */
}
return runawayfound(runner);
{
/* Purpose: to signal to the reader to be updated in terms of statistics, */
/* number or returns, latest found, then print motivational and help number */
/* message strings. runawayfound means that the structure node/element that */
/* the runaway node record fields now get inserted into a new return node. */
found = 1; /* found yet still lost */
returned = 0; /* found but not returned */
motivated = 1; /* found and motivated */
lost = 1; /* lost but found */
gotHelp = 1; /* runaway runner got help */
safe = 0; /* found but not returned or safe */
}
return runawayreturn(runner);
{
/* Purpose: to signal to the reader to be updated in terms of statistics, */
/* number or returns, latest found, latest returned, then print motivational */
/* and help number message strings. runawayreturn means that the structure node */
/* or element that the runaway node record fields now get inserted into a new */
/* return node. */
returned=1; /* not lost and safe */
found = 1; /* found and safe */
motivated = 1; /* motivated and got help */
GotHelp = 1; /* got help and motivated */
lost = 0; /* not lost and found */
safe = 1; /* found and safe */
}
def motivational();
{
/* Purpose: to signal to the reader to print a new motivational message and */
/* call helpresources() */be updated in terms of statistics, */
lost = 1;
motivated = 0;
Got help = 0;
Got help = 1;
Lost = 0;
print_stats();
helpresources();
}
def helpresources();
{
/* Purpose: to signal to the reader numbers that can be called toll free for */
/* help in being found, and reader to be updated in terms of statistics, */
motivated = 1;
GotHelp = 1;
motivational();
}
def return_list():
{
/* Purpose: to signal to the reader to be updated in terms of statistics, */
/* number or returns, latest found, latest returned, then print motivational */
/* and help number message strings. returnlist means that the structure node */
/* or element that the runaway node record fields now get inserted into a new */
/* return node. */
Return = Runner;
motivated =1;
GotHelp = 1;
found = 1;
safe = 1;
}
void print_stats()
{
/* Purpose: to signal to the reader to be updated in terms of statistics, */
/* number or returns, latest found, latest returned, then print motivational */
/* and help number message strings. runawayfound means that the structure node */
/* or element that the runaway node record fields now get inserted into a new */
/* return node. */
while (n = 0)
{
read x
if (x = sentinel);then
n = n+1
y[n] = x
call_sort(y,n)
sum=0
for(i=0;i <= n;i++)
{
sum = sum+y
}
mean = sum/n
j = (n/2)
if (n/2-j = 0)
{
median = y[j]
else
median = (y[j]+y[j+1])/2
}
sum = 0
for (i=0;i<=n;i++)
{
sum = sum+(y-mean)^2
}
variance = sum/n-1
std_dev = sqrt(variance)
coeff_var = std_dev/mean
printf ("\nN:%f MEAN:%f MEDIAN%f\n",&n,&mean,&median)
printf ("\n%f %f",&x[j],&x[n])
printf ("\nVARIANCE:%f STD_DEV:%f COEFF_VAR:%f\n",&variance,&std_dev,&coeff_var)
}
}
runner runaway_list():
{
/* Purpose: to signal to the reader to be updated in terms of statistics, */
/* number or returns, latest found, latest returned, then print motivational */
/* and help number message strings. runawayfound means that the structure node */
/* or element that the runaway node record fields now get inserted into a new */
/* return node. */
# Set total Runaways R = 0
R=0
# Open file for read
*fp=fopen("RunFile.dat","r+")
# Loop R through file RunFile
fseek("RunFile",0,0)
while (*fp != NULL)
do
fread("RunFile",&i)
R=R+R
# Return Runaways=R
done
# Close RunFile
fclose("RunFile")
}
def return_list():
{
/* Purpose: to signal to the reader to be updated in terms of statistics, */
/* number or returns, latest found, latest returned, then print motivational */
/* and help number message strings. runawayfound means that the structure node */
/* or element that the runaway node record fields now get inserted into a new */
/* return node. */
# Set total Returns R = 0
R=0
# Open file for read
*fp=fopen("RetFile.dat","r+")
# Loop R through file RetFile
fseek("RetFile",0,0)
while (*fp != NULL)
do
fread("RetFile",&i)
R=R+R
# Return Returns=R
done
# Close RetFile
fclose(RetFile)
}