Browse Source

Merge branch 'fixprint' of UBB/sort into master

Chris Cromer 7 months ago
parent
commit
d65c8fbb33
2 changed files with 6 additions and 5 deletions
  1. 3
    2
      src/count_sort.c
  2. 3
    3
      src/sort.c

+ 3
- 2
src/count_sort.c View File

@@ -13,6 +13,7 @@
13 13
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 14
  */
15 15
 
16
+#include <stdio.h>
16 17
 #include <stdlib.h>
17 18
 #include <string.h>
18 19
 
@@ -26,12 +27,12 @@ void count_sort(int *array, int n) {
26 27
 	int j;
27 28
 	int *temp = malloc(sizeof(int) * n);
28 29
 	if (temp == NULL) {
29
-		fprintf("Error: Out of heap space!\n");
30
+		fprintf(stderr, "Error: Out of heap space!\n");
30 31
 		exit(5);
31 32
 	}
32 33
 	int *count = malloc(sizeof(int) * n);
33 34
 	if (count == NULL) {
34
-		fprintf("Error: Out of heap space!\n");
35
+		fprintf(stderr, "Error: Out of heap space!\n");
35 36
 		exit(5);
36 37
 	}
37 38
 	memcpy(temp, array, sizeof(int) * n);

+ 3
- 3
src/sort.c View File

@@ -83,7 +83,7 @@ int read_buffer(int *variable) {
83 83
 	}
84 84
 	char **check = malloc(sizeof(char**));
85 85
 	if (check == NULL) {
86
-		fprintf("Error: Out of heap space!\n");
86
+		fprintf(stderr, "Error: Out of heap space!\n");
87 87
 		exit(5);
88 88
 	}
89 89
 	long input = strtol(buffer, check, 10);
@@ -203,12 +203,12 @@ int main (int argc, char **argv) {
203 203
 
204 204
 	unordered_array = malloc(sizeof(int) * n);
205 205
 	if (unordered_array == NULL) {
206
-		fprintf("Error: Out of heap space!\n");
206
+		fprintf(stderr, "Error: Out of heap space!\n");
207 207
 		exit(5);
208 208
 	}
209 209
 	work_array = malloc(sizeof(int) * n);
210 210
 	if (work_array == NULL) {
211
-		fprintf("Error: Out of heap space!\n");
211
+		fprintf(stderr, "Error: Out of heap space!\n");
212 212
 		exit(5);
213 213
 	}
214 214
 	atexit(cleanup);

Loading…
Cancel
Save