0
  #include<stdio.h>
  #include<string.h>
  unsigned int FindFunctionDefn(  char strFunctionName[],  char 
  strSourceCode[] ){
   int n = strlen(strSourceCode);
   int m = strlen(strFunctionName);
   int i = 0;
   unsigned int  line = 0;
   char new[300];
   char* p;
   int t=0;
   for(i=0;i<n;i++)
      {   if (strSourceCode[i]!='\n'){
          new[t] = strSourceCode[i];
           }

      if (strSourceCode[i] == '\n'){
      t=0;
      line = line + 1;
      p=strstr(new,strFunctionName);
      if (p){
        printf("%s \n",p);
        printf("%d",line); } }

       }
       return line;
      }

     int main(void){
     char strFunctionName[] = "func2";
     char strSourceCode[] =  "int func1(){ return 0; }\\n int func2(){ 
     return 1; }\\n" "int main(int argc, char*argv[]){ return func2(); 
     }\\n";
     FindFunctionDefn( strFunctionName, strSourceCode );
     }

enter image description here

1
  • OK, better. Now, edit the question and give some more context. What output do you expect, what do you THINK is the problem, what have you tried to change, what is your thinking. Just posting a question title, the code and the assignment isn't good enough. Also, how does this relate to CS50? Or is this a question related to c/c++ in general, or perhaps another class?
    – Cliff B
    Nov 11, 2018 at 17:11

1 Answer 1

2

The CS50 StackExchange is for questions about the CS50 course (and problem sets, etc.).

It is not a general "I need help with my homework from another course."-forum.

I'd suggest that if this is not CS50-related, and I see no indication that it is, that you choose another forum. Perhaps Stack Overflow?

Not the answer you're looking for? Browse other questions tagged .