Recent Posts
None | 13 sec ago
C# | 1 min ago
Delphi | 1 min ago
Delphi | 1 min ago
Delphi | 1 min ago
Delphi | 2 min ago
C# | 2 min ago
PHP | 2 min ago
PHP | 2 min ago
Delphi | 2 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Anonymous on the 9th of Feb 2010 10:20:16 PM Download | Raw | Embed | Report
  1. char *InsertString(char *Data, char *InsertAfter, char *InsertData);
  2.  
  3. int main()
  4. {
  5.         char *blah;
  6.  
  7.         blah = InsertString("<html> </html>", "<html>", "<title>test</title>");
  8.         printf("%s\n", blah);
  9.         return 1;
  10. }
  11.  
  12. char *InsertString(char *Data, char *InsertAfter, char *InsertData)
  13. {
  14.         char *newData = (char*) malloc(strlen(Data) + strlen(InsertData) + strlen(InsertAfter) + 1);
  15.         int pos;
  16.  
  17.         strcpy(newData, Data);
  18.         pos = strspn(Data, InsertAfter);
  19.         printf("%s - POS: %d\n", InsertAfter, pos);
  20.         memmove(newData+pos,InsertData, strlen(InsertAfter)+strlen(InsertData));
  21.        
  22.         return newData;
  23.  
  24. }
  25.  
  26. /*
  27.         Result: <html><title>test</title>
  28.         Expected: <html><title>test</title></html>
  29. */
Submit a correction or amendment below. [ previous version ] | [ difference ] | Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: