Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

can any1 pls check this code and tell if ther's anythin wrong?

Computer Science
See more answers at
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer


To see the expert answer you'll need to create a free account at Brainly

void copy(char **array,char name[10]) { FILE *fp; fp=fopen(name,"r"); char c; int i=0,j=0,flag=0,m=0; while((c=getc(fp))!='\n') { if(c==' ') { flag++; if(flag==1) { m=0; array[i][j]=' '; j++; } else if(flag==3) { j=0; array[i][j]='\0'; i++; flag=0; fseek(fp,-m,1); } } else { array[i][j]=c; j++; } m++; printf("%c %c\n",array[i][j],c); } fclose(fp); return; }
it is supposes to copy groups of three words into a 2d array... @farmdawgnation
ex: this is a test file this is a is a test a test file

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Are you seeing a problem with the code as is? Knowing what's wrong would help.
like array[i][j] and c prints different characters and array[i][j] prints garbage values
this is the total code if u wanna run #include #include #include //int length(char name[10]); char** makeArray(int n); void copy(char **,char name[10]); //void compare(char **array,char name[10],int x); //int count(char name[10]); main() { int k=0,x; char name[10]; printf("enter the name of the file:"); scanf("%s",name); int i,j,comp[10]; char **array; x=length(name); array=makeArray(x); copy(array,name); /*for(j=0;j
You're never allocating memory for array for starters.
i did and passed the array as an argument r8
Yowza segmentation fault.
You're doing something you're not supposed to :P
i dint get any segmentation fault
``` enter the name of the file:testfile the number of phraes:3,max size of word:7 3007 ? t 2 h ? i ? s  i s , a i s a t e s t a t e s t f i l e Segmentation fault: 11 ```
BTW. Single letter variable names suck. :P
Yeah man, I'm not sure what's going on. I don't really feel like spending three hours with gdb digging into it to figure it out. I don't really have that much free time atm. :/
FWIW I don't see anything obvious.
hmmm thanks anyway....if u find anythin lemme kno
lol not a bigg thing....the print statement was showing some random values coz.... of j!!! ie the next character that's not copies yet!!
nd that xplainds the seg fault too

Not the answer you are looking for?

Search for more explanations.

Ask your own question