gets(p[j]); //use scanf
puts(p[j]); //use printf
zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 13
zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 13
Also don't forget to free the memory after use
for(j=0;j<noe;j++){
free(p[i]);
}
free(p);
zeroliken
Nearly a Posting Virtuoso
1,346 posts since Nov 2011
Reputation Points: 214
Solved Threads: 205
Skill Endorsements: 13
The enter u put when u input 5 will remain in the input buffer as a newline.
Gets reads from input buffer until it sees a newline and then it removes it from the buffer(but does not add it to the string). So the first gets will remove the newline and the second gets will accept the first input and so on. fgets also stops after accepting newline(but fgets adds newline also to the string)
v3ga
Junior Poster in Training
95 posts since Oct 2011
Reputation Points: 14
Solved Threads: 5
Skill Endorsements: 0
v3ga
Junior Poster in Training
95 posts since Oct 2011
Reputation Points: 14
Solved Threads: 5
Skill Endorsements: 0