CProgPart3 - sort(words, numwords); print_strings(words,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
C Language Programming Part 3 /******************* Homework Assignment 1 Part 3 By: /******************/ #include <stdlib.h> #include <stdio.h> #include <string.h> #define MAXLINES 25 void swapsp( char *p[], int n); void sort( char *p[], int n); void print_strings( char *p[], int n); main() { int numwords = 30; char *words[30]={ "computer", "hard", "soft", "clear", "message", "button", "compact", "laser", "mouse", "speaker", "error", "disk", "simple", "complex", "inside", "watch", "bay", "already", "pixel", "nano", "binary", "hex", "decimal", "java", "light", "mega", "giga", "water", "caffiene", "camel"};
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: sort(words, numwords); print_strings(words, numwords); system ("PAUSE"); return (0); } void sort( char *p, int n) { int a, b; char *x; for (a = 1; a < n; a++) { for (b = 0; b < (n-1); b++) { swapsp(p, b); } } } void print_strings( char *p, int n) { int counter; for (counter = 0; counter < n; counter++) printf("%s\n", p[counter]); } void swapsp( char *p, int b) { char x; if (strcmp(p[b], p[b+1]) > 0) //strcmp to compare strings { x = p[b]; p[b] = p[b+1]; p[b+1] = x; } }...
View Full Document

This note was uploaded on 03/30/2008 for the course CS 212 taught by Professor Dr.frey during the Spring '06 term at New Haven.

Page1 / 2

CProgPart3 - sort(words, numwords); print_strings(words,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online