Output without coding display

closed account (1vf9z8AR)
How i can make a file to display the output of c++ coding done in codeblocks without displaying the coding.
I would prefer the file to be cross platform.

Thankyou:)
compile the source file through C::B, look for the executable (with .exe suffix, same name as source file, created in the same folder) - this runs the program w/o displaying the code
An .exe is not cross platform, it run's only the platform where it was compiled.
you can write the output to a web page (which can be a flat text file, as browsers will display those) in a location that your network or the web itself can see) and view it from anywhere.

You can make a web page call the .exe program on the server with some work on the web page, and then drop the results into itself or a new page.

Is this what you are asking?
I would prefer the file to be cross platform.

true, it's on the OP"s wish-list. let see what other suggests come in, interesting
does cross platform file exist ?
(I don't think so unless you put it on the web and compile it in website)
anyways smart choice of using codeblocks
jonnin wrote:
a web page (which can be a flat text file, as browsers will display those)

It looks a canny solution. The only limit I can see is perhaps you will need either to stuck to the English alphabet or use html entities or create your file as an utf-8 file with BOM, otherwise it's not guarantee it will be displayed correctly.
closed account (1vf9z8AR)
how do i do it using website?
i want to put it on my pendrive so that my teacher can see my program but my school has all kinds of operating systems and can't tell her to use only windows.
Last edited on
I am afraid you can't do it. When you compile your program on Windows it will run only on Windows. If you compile it on a Mac it will run only on a Mac.
One option is to show her the .cpp file so she can compile and run it herself.
Another option is to use Java, it will run on any machine that has a Java runtime installed.
Lets be precise, the OP seems a little new to all this.
OP..
1) you can give the output as text or other formats that ALL os can read and work with.
2) you can provide a compiled program but the user can either only use it on one type of operating system or has to do something aggravating like run through a virtual machine.

as for all this ... it seems to me your teacher should tell you what to turn in. If not, ask.

3) Just to clarify what has been said, c++ is a compiled language. It produces an executable file that is tied to one type of OS and hardware (again, you can trick around this with virtual machines). If you want to run it on multiple OS, you need to write the code so it uses no OS specific libraries, headers, or extensions, and then you can compile it on each target machine. This is a lot of trouble for professional code but only a minor aggravation for classwork and utility code.



jonnin wrote:
you can write the output to a web page (which can be a flat text file, as browsers will display those)
suyashsing234 wrote:
how do i do it using website?
i want to put it on my pendrive so that my teacher can see my program but my school has all kinds of operating systems and can't tell her to use only windows.

I’m just answering you about your first question, since I think you’ve already got plenty of explanation about the second.
(Just to contradict myself: about your second question... Are you really the only Windows user in your class?)

As jonnin explained, html file are no more than plain text files which happen to contain both text (for the reader) and instructions (for the browser) for displaying that text. The trick is if browsers can’t find any instructions for them, they display the text more or less as it is.
As a result, if you create a text file and you set its extension as ‘.html’, you can open it with a browser and read its content.
The following code creates a file named "suyashsing234.html" where’s written "Hi, I've successful created an HTML file!". If you double click on it, your default browser should open it and correctly show its content, regardless of your operative system.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <fstream>
#include <iostream>
#include <limits>


void waitForEnter();


int main()
{
    std::ofstream myout("suyashsing234.html");
    myout << "Hi, I've successful created an HTML file!\n";
    std::cout << "Please find \"suyashsing234.html\".\n";
    myout.close();
    waitForEnter();
    return 0;
}


void waitForEnter()
{
    std::cout << "\nPress ENTER to continue...\n";
    std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}


Granted it’s a great solution for those who need to write in English and English only, it’s got some limits. All these technologies have been mainly developed in USA and their developers only took into account what’s there on an English keyboard. If you need to display some characters that are not in the English alphabet, I’m afraid things won’t be so easy.
Possible solutions are:
1) Use only English alphabet and explain your teacher you couldn’t find a better solution.
I may appreciate that, if you’re native speaker of one of those thousands of languages that don’t come from the Latin alphabet, this sounds a terrible solution.

2) use html entities.
HTML entities are short ‘aliases’ for those characters which don’t appear in the English alphabet.
For example, if you want to write the German letter ß (in English: “SZ ligature”), you can write “&szlig;” and your browser will display it correctly.
Again, if you needed to apply this method to all characters, it would be a nightmare.

3) Create you text file as utf-8 with BOM.
Modern browsers can display correctly those file in any languages they are written (but I personally don’t include Apple Safari in the directory of modern browsers). This is probably the best solution if your language doesn’t share characters with the English alphabet.
I’ve never created an utf-8 with BOM file, but it doesn’t look so hard. Anyway, this forum will be still there to ask for help :-)
Topic archived. No new replies allowed.