How can you make a program ends when the user enters the string "terminate"?
samernic
0
Newbie Poster
Recommended Answers
Jump to PostIf you're in main and not some nested function call you can simply return and the program will end. Otherwise, there's a function called exit in stdlib.h that does the same thing from anywhere in the program. Do you know how to take a string as input and compare it …
Jump to PostHmm, interesting that your problem is comparing strings. In this case you would use strcmp:
if ( strcmp ( buffer, "terminate" ) == 0 ) { // Notify the other program of termination return 0; }
All 5 Replies
Narue
5,707
Bad Cop
Team Colleague
samernic
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
samernic
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
Salem
commented:
You'd think someone who managed IPC could have figured out strcmp() - Salem
+6
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.