Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help me debug the code below. Error message: In function sortArguments: error: expected expression before ] token list = convertToInt(argv[]); ^ user input example: ./runMe

Help me debug the code below. Error message: In function sortArguments: error: expected expression before ] token list = convertToInt(argv[]); ^ user input example:  
./runMe 0 234 345345 91 -3 12 3 19 17 

code:

void sortIntegers(int value[], int length) { int i,j; int temp; for(i=0;ivalue[j+1]){ temp = value[j+1]; value[j+1] = value[j]; value[j] = temp; } else{ continue; } } } } int convertToInt(char *string) { int integer; integer = atoi(string); return integer; } int *sortArguments(int argc, char *argv[]) { int *list = malloc(sizeof(int) * (argc-1)); list = convertToInt(argv[]); sortIntegers(list,argc-1); return list; } int main(int argc, char *argv[]) { int i = 0; int *result; printf("Hello, World "); printf("Before: "); for (i = 1; i < argc; i++) { printf("%s, ", argv[i]); } printf(" "); result = sortArguments(argc, argv); printf(" After: "); for (i = 0; i < argc-1; i++) { printf("%d, ", result[i]); } free(result); return 0; }

 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago

Question

Describe global employee and labor relations practices.

Answered: 1 week ago