#How to convert this simple program into a windows application

1 messages · Page 1 of 1 (latest)

ivory thistle
#
using namespace std;
int a[5],n,test;

string ppl[6][6]={{"1","2","3","4","5"},{"1","2","3","4","5"},{"1","2","3","4","5"},{"1","2","3","4","5"},{"1","2","3","4","5"}};
int main() {
    cin>>n;
    freopen ("duty.txt","r",stdin);
    for (int i=0;i<5;i++) cin>>a[i];
    fclose(stdin);
    
    if (n==0){
        freopen ("duty.txt","w",stdout);
        for (int i=0;i<5;i++){
                if (a[i]==5) cout<<1<<endl;
                else cout<<a[i]+1<<endl;
            }
        fclose(stdout);
    }
    else if (n<=5&&n>0){
        cout<<"Group "<<n<<": "<<endl;
        for (int j=0;j<5;j++) cout<<"No."<<j+1<<": "<<ppl[n-1][j]<<endl;
    }
    else
        for (int i=0;i<5;i++){
            cout<<"Group: "<<i+1<<" ";
            for (int j=0;j<5;i++)
                cout<<ppl[i][j]<<" ";
            cout<<endl;
        }
        
    return 0;
}```
subtle gateBOT
#

@ivory thistle

It looks like you may have code formatting errors in your message

Note: Make sure to use back-ticks (`) and not quotes (')
Note: Make sure to specify a highlighting language, e.g. `cpp`, after the back-ticks

Markup

```cpp
int main() {}
```

Result
int main() {}
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

ivory thistle
#

🙂

#

this is a homework assigned by my teacher

#

desperately need help~

keen wraith
#

Don't include bits/stdc++, that's for internal use by the compiler

#

Wdym by windows application? To make it compile and run on Windows?

ivory thistle
#

to change it into a windows app

keen wraith
#

What does that mean? A GUI?

ivory thistle
#

like change it into a runnable app for every windows users

keen wraith
#

Looks like it already can technically

#

You just need to compile it

ivory thistle
#

it can't be compiled for those who don't have a c++ compiler

keen wraith
#

Obviously

#

You can compile it and give other people the executable

ivory thistle
#

So I want it to convert to an application, so that all windows users can run

keen wraith
#

When you compile code it makes an executable that you run

ivory thistle
#

oh

keen wraith
#

And that runs your program

ivory thistle
#

how about mac users?

keen wraith
#

You can't run a Windows program on a Mac and vice versa

ivory thistle
#

I know

#

so how can I convert the exe to something that mac can use

keen wraith
#

You need to compile the code with a compiler capable of producing an executable Mac can run

#

So Clang most likely

#

Are you on Windows?

ivory thistle
#

I am on windows

ivory thistle
subtle gateBOT
#

@ivory thistle Please do not send executable files

ivory thistle
#

.

#

which is the executable for this

#

but when I double click it

keen wraith
#

Idk if you can compile an executable for Mac from Windows tbh, it sounds like it'd be annoying to do

ivory thistle
#

it shows a terminal and closed it instantly

keen wraith
#

It closed cause the program finished

ivory thistle
#

I didn't even see the output

#

ha

keen wraith
#

You can pause at the end or run in a command prompt so you can still see the output after it finishes

#

Are you using Visual Studio?

ivory thistle
#

dev c++

#

I do have visual studip

#

vs code

keen wraith
ivory thistle
#

ye

#

this line?

quaint solar
ivory thistle
#

system(“pause”)

ivory thistle
#

:/

quaint solar
#

You sure you didn't misunderstand him?

ivory thistle
#

it like an additional mark

#

it optional

#

and I wanna do it

quaint solar
#

Maybe he just wants the .cpp file? A mac executable sounds weird

#

There's a tool called Wine that can run Windows programs on other OSes, including on Mac. If they use it, they'll be able to run it as is

ivory thistle
#

he says it just a fun challenge, and he will give us an additional mark if we can give him a sort of application that works on his computer

quaint solar
#

Ah lol

#

Then asking us is kinda cheating, isn't it? 😛

ivory thistle
quaint solar
#

No, it doesn't produce a new executable. It runs the existing one

#

That's how folks on linux play windows games, for example

#

Look up cross-compilation. This means compiling for a different OS compared to the one you're using

#

There are tools to cross-compile to mac

ivory thistle
#

Alright

ivory thistle
midnight mauve
#

it block sending exe files?

fickle lotus
ivory thistle
#

didn't he say it a tool to compile?

subtle gateBOT
#

@midnight mauve Please do not send executable files

fickle lotus
midnight mauve
#

no its not...

#

just compile on mac

fickle lotus
#

or use zig c++

ivory thistle
#

what is zig c++

fickle lotus
ivory thistle
#

So I have to learn a whole new language??

quaint solar
# ivory thistle this?

No, as I said. Wine runs windows executables on mac, it doesn't create the actual mac executables. That's likely not what they want.
There are tools to produce mac executables without having a mac, this process is called cross-compilation

midnight mauve
#

zig xD

fickle lotus
#

i meant zig c++, not zig

ivory thistle
#

ohhhh

fickle lotus
#

zig c++ <your_file>.cpp -target x86_64-macos

ivory thistle
fickle lotus
#

or i think it's aarch64-macos-gnu instead

ivory thistle
#

I am confused for that command xd

fickle lotus
#

either of them

ivory thistle
#

where do I enter that

#

Maybe I will try it tmrw, I have class on Thursday, hopefully I can do it

#

btw, 5 more message then this chat would reach 100

fickle lotus
#

you'll also need MacOS SDK

quaint solar
#

Meh

#

Cross-compilation can be interesting, but copying commands we give you without understanding, just to get marks? I dunno

ivory thistle
#

where do i even enter those command

ivory thistle
quaint solar
#

See? notlikethis

fickle lotus
ivory thistle
#

did research on the freopen

quaint solar
#

That's something else entirely

ivory thistle
#

now i just need to make it an app

ivory thistle
#

couldn't find anything useful

quaint solar
#

Because you didn't know how the process is called ("cross-compilation")

#

Try googling cross-compile c++ from windows to mac

ivory thistle
#

I will close this for now I guess

quaint solar
ivory thistle
#

okay

#

thanks a lot

#

!solve