Question: Challenge Description Read in a string as a command-line argument (scanf, fgets, gets, etc. may not be used). See the example program run below. If

Challenge Description

  • Read in a string as a command-line argument (scanf, fgets, gets, etc. may not be used). See the example program run below.
  • If no command-line argument is given, output a message telling the user the expected usage, and then terminate.
  • Write a function (separate from main) that takes the user's input string as an argument and determines the sub-string consisting of the odd characters in the input string (see the example output below).
  • Write a function (separate from main) that takes a string as a parameter and returns a variable indicating whether the string is a palindrome.
  • Output the odd string to the screen, and also a message saying whether or not the odd string is a palindrome.
  • The program must work successfully with input strings of any size, and you must use dynamic memory allocation (malloc and free must be used).
  • You must use valgrind to check your program for errors and memory leaks. If valgrind shows any errors or memory leaks, there will be a grade deduction even if the program seems to run ok. The amount of the deduction could be small or large depending on the nature of the error..

Sample Program Output

Example program run: ./challenge_5.exe abcda Example output:

odd string = aca this (aca) is a palindrome

You can generate more sample outputs by running a sample executable: challenge_5.exe

Submit

A gzipped tarball in the form: username_c5.tar.gz

where username is your unique ID. When expanded, the tarball must produce a directory named USERNAME_C5 (where USERNAME is your unique ID) that contains the following, and nothing else:

  • your C program file(s) and any header (*.h) file(s)
  • a Makefile that generates an executable called challenge_5.exe from your program and header files

Notes

Everything must work on the Linux server. Late assignments will not be accepted. The following are some examples of things that may result in significantly reduced credit for the assignment:

  • Tarball filename does not follow the required format
  • Tarball expansion fails
  • Failure to tarball the directory with the structure described above
  • Missing or non-functional Makefile
  • Program doesn't compile
  • Program does not use dynamic memory allocation (malloc and free)

Useful Resources

  • No need to write a Makefile from scratch. Just edit this Makefile. You only need to edit two variables in the Makefile: OBJS and EXEO.

Makefile:

CC = gcc WARN_FLAGS = -Wall DEBUG_FLAGS = -g INC_FLAGS = FLAGS = $(DEBUG_FLAGS) $(WARN_FLAGS) $(INC_FLAGS)

LIB = SRC_DIR = ./ OBJS = program.o EXEO = program.exe

$(EXEO): $(OBJS) $(CC) $(FLAGS) $(OBJS) -o $(EXEO) $(LIB)

%.o: $(SRC_DIR)/%.c $(CC) $(FLAGS) -c $< -o $@

clean: rm -f *.exe rm -f *.o

I can do the tarballing of the files. Make sure that code is in C and that the Makefile executes the program!!!!!!

Thank you so much!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!