How can I apply HTML / CSS to a pure C program?

3

The programming club I'm attending has completed a program that functions as a stock controller and shows things that are available and things borrowed.

It was done in pure C, so the display is quite archaic,

It looks like this: | Control 1 | Available |

And I'm wondering if I could do something like this:

table, th, td {
    border: 1px solid transparent; border-collapse: collapse;
    text-align: left;    
    width: 100%; 
    font-family: "Comic Sans MS", cursive, sans-serif;
    padding: 0.3em;
    border-radius: 25px;
}

table, th{background-color: lightBlue; }

td{background-color: steelBlue;border-radius: 0px;}

#ultimo {border-bottom-left-radius: 0;}
<table>
<tr>
    <th>Controle 1</th>
    <td>Disponível</td>
</tr>
<tr>
    <th>Controle 2</th>
    <td>Emprestado</td>
</tr>
<tr>
    <th>Controle 3</th>
    <td>Disponível</td>
</tr>
<tr>
    <th>Controle 4</th>
    <td>Emprestado</td>
</tr>
<tr>
    <th>Controle 5</th>
    <td>Disponível</td>
</tr>
<tr id="ultimo">
    <th>Controle 6</th>
    <td>Disponível</td>
</tr>
</table>

So it's very uninteresting, and every time there's a change on the page (like something borrowed), the page needs to be updated.

The question is: would I have some way to use the program in an HTML rendered interface - and CSS, better still - ie use c as a JSP (or PHP or JS not yet mastered that area). Of course, it would be much more feasible to translate this idea into another language, but our goal is to learn as much as possible of the language, and doing that would be a great achievement!

    
asked by anonymous 16.07.2017 / 00:10

1 answer

6

Yes and no. C can output texts wherever you want any way you want. HTTP servers receive texts of whatever technology they want as long as they meet certain standards, especially CGI or some other way of communicating with the server, which by the way must have been developed in C or C ++, then it is very easy for them to speak by means other than direct texts. It is there to choose the form you want to communicate, to study its protocols and to have C interact accordingly.

The C itself, pure as you are saying, has nothing ready for this, even more so with ease in which you mount a file that will be interpreted by the application and will do something with no additional worry. There are libraries that can help in this to a lesser or greater extent.

But I already added that most people do not use C to do anything web, it's not a very productive language. In general, C is used to make operating systems, servers, drivers, on-board programming, or other things that need maximum performance, hardware control, and memory manipulation. Even some things that need it all but not in the extreme use C ++. There are a few more attempts to use web in C ++, but little. The bulk is used Java, C #, PHP, and the like.

I would not worry about trying to do this in C, even because if I master C as it should, and few people who start it do it, we see here all the time all the staff learning C all wrong, doing something for the web is the of less, is something almost bureaucratic.

    
16.07.2017 / 00:24