Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

breaking out of a void return function

dilate02dilate02 Member Posts: 12
does anyone know how to break out of a function that has a void function? for example,

void insertBST(KeyType k, int lineNum, BST t)
{ PtrToBSTNode p=t->root;
while(p!=NULL)
{ if(strcmp(k, p->key == 0)
InsertLineList(lineNum, p->l); /* <-how can you stop*/
else p=p->right; /* the function here? */
...
}
p->key =malloc(strlen(k));
strcpy(p->key, k);
}

any help would be greatly appreciated. thank you!
-christine

Comments

  • pingpongpingpong Member Posts: 937
    use "return"

    : does anyone know how to break out of a function that has a void function? for example,
    :
    : void insertBST(KeyType k, int lineNum, BST t)
    : { PtrToBSTNode p=t->root;
    : while(p!=NULL)
    : { if(strcmp(k, p->key == 0)
    : InsertLineList(lineNum, p->l); /* <-how can you stop*/
    : else p=p->right; /* the function here? */
    : ...
    : }
    : p->key =malloc(strlen(k));
    : strcpy(p->key, k);
    : }
    :
    : any help would be greatly appreciated. thank you!
    : -christine
    :

  • _transmission__transmission_ Member Posts: 1
    no dont use return
    you have to use exit(), its included in conio.h i think
  • PatLDDDPatLDDD Member Posts: 30
    : no dont use return
    : you have to use exit(), its included in conio.h i think
    :
    Hello,

    exit() will quit the program...And I belive that not what we what here.

    Return will only quit the current function.

    Pat
  • Andre YoungAndre Young USAMember Posts: 0

    ___ \ http://forcoder.org \ free video tutorials and ebooks about // Ruby, Swift, JavaScript, Assembly, Go, Scratch, PHP, Perl, C++, PL/SQL, Python, Visual Basic .NET, C#, C, R, Objective-C, Visual Basic, Java, MATLAB, Delphi Dart, Scheme, Lisp, FoxPro, Julia, Transact-SQL, Ada, Awk, Lua, Hack, Erlang, Prolog, Scala, F#, LabVIEW, COBOL, Apex, Kotlin, Crystal, Bash, D, Rust, Fortran, Logo, SAS, ABAP, ML, Alice, Clojure, VBScript // _____

Sign In or Register to comment.