• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

C Word concordance

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am very new to C programming. I have a program that is suppose to take 3 command line arguments and read from a file a list of words. Then it is suppose to print them in an output file with the word and the number of times it occurs.
The problem I am currently having is the program does nothing and just crashes and not sure what to do.

command to be entered



My current code.
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Have you any idea how far the program runs before crashing? Do you get a plain simple segfault error message, or something more informative? Have you tried any debugging?
Where does the qsort function come from? Is it in one of the .h files you are including? What do the two text files look like?
 
Spencer Mist
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to the Ranch

Have you any idea how far the program runs before crashing? Do you get a plain simple segfault error message, or something more informative? Have you tried any debugging?
Where does the qsort function come from? Is it in one of the .h files you are including? What do the two text files look like?



the proj2.out file is just the output of the program sorted with the word and the number of times it occurs.

The proj2.in file looks like
Proj2.in
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

According to your code ...

Spencer Mist wrote:

Your input file, and your output file, are the same file.

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic