Can I apply HTML/CSS to a pure C program?

Asked

Viewed 1,925 times

4

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

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

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 little interactive, and every time there’s a page change (like something borrowed), the page needs to be updated.

The question is: I would have some way to use the program in an interface rendered in HTML - and CSS, better yet - that is, use c as a JSP (or PHP or JS did not yet dominate 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 of the language as possible, and to do so would be a great achievement!

1 answer

7


Yes and no. C can send texts to where you want them to be. HTTP servers receive text from any technology you want as long as it meets certain standards, especially the CGI (a little outdated) or some other way to communicate with the server, which by the way must have been developed in C or C++ (today this is already less true in some cases), so it is very easy for them to speak by means other than direct texts. Here is to choose the way you want to communicate, study your protocols and make the C interact accordingly.

The C itself, pure as you’re saying, doesn’t have something ready for it, especially with facilities where you assemble a file that will be interpreted by the application and will do something without any further concern. There are libraries that can help this to a lesser or greater degree.

But I would point out that most people don’t use C to make something web, it’s not a very productive language. In general C is used to make operating systems, servers, drivers, Embedded programming, or other things that needs maximum performance, hardware control and memory manipulation. Even some things that need it all, but not in the extreme, use C++. There are a little more attempts to use the web in C++, but little. The bulk is used Java, C#, PHP, and things like.

I wouldn’t worry about trying to do this in C, not least because if C dominates as it should, and few people who start do it, we see here all the time people learning C all wrong, doing something for the web is the least, it’s almost bureaucratic.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.