Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Does C have anything like the `substr extract substrin routine present in other languages?
Does C have anything like the `substr extract substrin routine present in other languages?
✍: Guest
Not as such. To extract a substring of length LEN starting at index POS in a source string, use something like
char dest[LEN+1];
strncpy(dest, &source[POS], LEN);
dest[LEN] = '\0'; /* ensure \0 termination */
char dest[LEN+1] = "";
strncat(dest, &source[POS], LEN);
or, making use of pointer instead of array notation,
strncat(dest, source + POS, LEN);
(The expression source + POS is, by definition, identical to &source[POS]
2016-03-07, 1183👍, 0💬
Popular Posts:
How To Use mysqlbinlog to View Binary Logs? - MySQL FAQs - Server Daemon mysqld Administration If yo...
Can each Java object keep track of all the threads that want to exclusively access to it?
Which bit wise operator is suitable for checking whether a particular bit is on or off? The bitwise ...
Can you explain Forms authentication in detail ? In old ASP if you where said to create a login page...
What is the difference between "printf(...)" and "sprintf(...)"? sprintf(...) writes data to the cha...