Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to link main function with header file and create it's dll file?
    primarykey
    data
    text
    <p>I am very beginner to work with dll and linking various file.</p> <p>I just know write main() function and all other in same .c file and run it.</p> <p>I have one program which works for pattern matching. It takes the string and check whether it exist in entire text string or not. like</p> <p>Text string: my name is john</p> <p>string to be matched: name</p> <p>Answer: Yes</p> <p>main function is like this:</p> <pre><code>int main(int argc, const char *argv[]) { char target[200]; char *ch = target; char pattern[20]; int i,k,count,l; printf("\nEnter the string: \n"); fgets(target,100,stdin); printf("Enter the string to be matched: \n"); fgets(pattern,20,stdin); l=strlen(pattern); i = kmp(target, strlen(target)-1, pattern, strlen(pattern)-1); //printf("I is : %d\n",i); if (i == -1) puts("False"); else puts("True"); getch(); return 0; } </code></pre> <p>Which calls function kmp() and get result back. We can also print the result in kmp() function. kmp() function is as follow:</p> <pre><code>int kmp(char *target, int tsize, char *pattern, int psize) { int i; int *pi = compute_prefix_function(pattern, psize); int k = -1; if (!pi) return -1; for (i = 0; i &lt; tsize; i++) { while (k &gt; -1 &amp;&amp; pattern[k+1] != target[i]) k = pi[k]; if (target[i] == pattern[k+1]) k++; if (k == psize - 1) { free(pi); return i-k; } } free(pi); return -1; } </code></pre> <p>In kmp we call <strong>compute_prefix_function(pattern, psize);</strong> which is as below:</p> <pre><code>int *compute_prefix_function(char *pattern, int psize) { int k = -1; int i = 1; int *pi = malloc(sizeof(int)*psize); if (!pi) return NULL; pi[0] = k; for (i = 1; i &lt; psize; i++) { while (k &gt; -1 &amp;&amp; pattern[k+1] != pattern[i]) k = pi[k]; if (pattern[i] == pattern[k+1]) k++; pi[i] = k; } return pi; } </code></pre> <p>Header files need to be called: </p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; </code></pre> <p>What I want to do is:</p> <p><em><strong>Creating an implementations in a dll/shared library format. essentially, the dll should have a function extension which take a string and return a bool saying if the string exists or not.</em></strong></p> <p>For that which function I need to put in .c file and header file and how to create .dll file for this?</p> <p>I am using windows 7, VS 2010 and C programming.</p> <p>Please explain me step by step.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload