Or login with:
| intdetect_bracket( | const char* | str | |
| int | offset | ||
| int | str_len | ||
| char | open = '{' | ||
| char | close = '}' | ) |
#include <codecogs/strings/search/detect_bracket.h> int main() { const char str[]="for(int i=1;i<10) { if(i==2) { printf(\"{%d}\",i) }else { printf('}') } } printf(\"the end of { detection }...\");"; printf("\nClosing bracket when starting at str[%d] is %d", 5, detect_bracket(str, 5, strlen(str))); printf("\nClosing bracket when starting at str[%d] is %d", 18, detect_bracket(str, 18, strlen(str))); printf("\nClosing bracket when starting at str[%d] is %d", 39, detect_bracket(str, 39, strlen(str))); return 0; }Output:
Closing bracket when starting at str[5] is 5 Closing bracket when starting at str[18] is 71 Closing bracket when starting at str[39] is 43
#include <codecogs/strings/search/detect_bracket.h> int main() { const char str[]="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td> </td>"; printf("\nClosing bracket when starting at str[%d] is %d", 0, detect_bracket(str, 0, strlen(str), '<', '>')); printf("\nClosing bracket when starting at str[%d] is %d", 18, detect_bracket(str, 18, strlen(str), '<', '>')); printf("\nClosing bracket when starting at str[%d] is %d", 39, detect_bracket(str, 39, strlen(str), '<', '>')); return 0; }Output:
Closing bracket when starting at str[0] is 50 Closing bracket when starting at str[18] is 18 Closing bracket when starting at str[50] is 54
| str | The input string containing the text to analyse |
| offset | An offset into the str. If str[offset] does not correspond to the open character for a bracket, then offset is returned by this function. |
| str_len | The length of the str, or the total length over which to search. Use strlen if you are unsure. |
| open | The character that defines an open bracket. Default Value = '{' |
| close | The character that defines a closed bracket. Default Value = '}' |
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.
You must login to leave a messge