Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,151 questions

40,705 answers

573 users

How to use the goto statement to get out of loop inside if statement in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

extern char **environ;

int main(int argc, char *argv[]) {

    if (environ != NULL) {
        for (size_t i = 0; environ[i]; ++i) {
            puts(environ[i]);
            if (strncmp(environ[i], "Common", 6) == 0) {
                puts("END");
                goto END;
            }
        }
        printf("environ not found\n");
    } END:


    return 0;
}



/*
run:

ALLUSERSPROFILE=C:\abcxyz
APPDATA=C:\abc\xyz\AppData\Roaming
asl.log=Destination=file
CommonProgramFiles=C:\Program Files (x86)\Common Files
END

*/

 





answered May 4, 2021 by avibootz

Related questions

1 answer 66 views
2 answers 86 views
2 answers 67 views
1 answer 59 views
...