Difference between revisions of "CSC231 Homework 7 2017"

From dftwiki3
Jump to: navigation, search
Line 1: Line 1:
 
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 08:28, 8 April 2017 (EDT)
 
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 08:28, 8 April 2017 (EDT)
 
----
 
----
 +
<br />
 +
<br />
 +
<br />
 
<center>
 
<center>
 
<font size="+2">Page under construction!</font>
 
<font size="+2">Page under construction!</font>
 
</center>
 
</center>
<P>
 
<P>
 
 
[[File:UnderConstruction.jpg|center|300px]]
 
[[File:UnderConstruction.jpg|center|300px]]
 
<br />
 
<br />

Revision as of 07:29, 8 April 2017

--D. Thiebaut (talk) 08:28, 8 April 2017 (EDT)





Page under construction!

UnderConstruction.jpg






Problem #1: Programming in C


  • Create the C program below, and run it. It will serve as the seed for your solution program for Problem 1.


/*
hw7_1.c
D. Thiebaut

This program gets a sstring from the command line and prints it on the screen.

*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//--------------------------------------------------------------------
//                           MAIN  PROGRAM
//--------------------------------------------------------------------
void main( int argc, char *argv[] ) {
  //--- variables ---
  int n, i, name;
  char sentence[100];
  char stars[100];

  //--- see if use entered arguments on the command line ---
  if ( argc < 2 ) {
    //--- No, didn't.  Print syntax information and quit ---
    printf( "Syntax: %s string [string...]\n", argv[0] );
    exit( 1 );
  }

  //--- print the arguments back to the user, with a dash in between ---
  for ( i = 1; i < argc; i++ ) {
    if ( i > 1 )
      printf( "-" );
    printf( "%s",  argv[i] );
  }
  printf( "\n" );

  //--- Done! ---
}
  • Here are different ways of using it...