C/C++ で system() を使用することの驚くべき点は何ですか?

王林
リリース: 2023-08-29 11:29:02
転載
1214 人が閲覧しました

在C / C++中使用system()的令人惊奇的东西是什么?

ここでは、C または C で system() 関数を使用した驚くべき結果をいくつか見ていきます。このシステム機能は、Windows、Linux、および MAC オペレーティング システムに存在します。この関数は、コマンド ラインに記述できるシステム コマンドを実行するために使用されます。

ここでは、C または C でのシステム関数の 2 つの使用法を見ていきます。 1 つ目は、C プログラムを使用して IP 構成の詳細を取得することです。

#include  #include  using namespace std; int main() { system("C:\Windows\System32\ipconfig"); }
ログイン後にコピー

出力

Windows IP Configuration Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : domain.name Link-local IPv6 Address . . . . . : fe80::302b:9dff:1cfb:ff01%10 IPv4 Address. . . . . . . . . . . : 192.168.2.6 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : fe80::217:7cff:fe3d:31c8%10 192.168.2.1 Ethernet adapter VirtualBox Host-Only Network: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::5c79:a124:f5b9:e0b7%13 Autoconfiguration IPv4 Address. . : 169.254.224.183 Subnet Mask . . . . . . . . . . . : 255.255.0.0 Default Gateway . . . . . . . . . : Ethernet adapter VirtualBox Host-Only Network #2: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::7c54:289:9257:dd7a%16 IPv4 Address. . . . . . . . . . . : 192.168.243.2 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : Tunnel adapter Teredo Tunneling Pseudo-Interface: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Tunnel adapter isatap.{E12FA520-1578-4264-A565-A1270D18177A}: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Tunnel adapter isatap.{A01195C5-0A34-4E50-89CB-4C391165B7C3}: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Tunnel adapter isatap.domain.name: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : domain.name
ログイン後にコピー

2番目の方が興味深いです。これを使用して、コンピュータをシャットダウンできます。システム関数にシャットダウンプログラムのパスを記述するだけです。

#include  #include  using namespace std; int main() { system("C:\WINDOWS\System32\shutdown /s"); }
ログイン後にコピー

出力

One box will appear. It will tail the system is shutting down, then it will be shut down.
ログイン後にコピー

以上がC/C++ で system() を使用することの驚くべき点は何ですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

ソース:tutorialspoint.com
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!