How to find the offset of the first wide-character that are part of wide-character string in C

1 Answer

0 votes
// Use wcscspn() — to find the offset of the first wide-character that are part 
// of wide-character string

#include <stdio.h>
#include <wchar.h>

int main(void)
{
    wchar_t s[] = L"cc++java";
    wchar_t sub[] = L"java";
    int pos;
    
    pos = wcscspn (s, sub);
    wprintf(L"%d\n", pos);
  
    return 0;
}

  
/*
run:
  
4

*/

 



answered Jun 22, 2017 by avibootz

Related questions

1 answer 277 views
1 answer 150 views
1 answer 176 views
1 answer 133 views
...