C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old November 22nd, 2002, 02:08 PM
flea17 flea17 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 1 flea17 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
using an array and passing it to a function (just learning)

Anyone see what is wrong with my code (I'm trying to use an array and passing it to a function). Thanks in advance!

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

void read (int*, int*, int*, int*);

void cat (char[][], char[][], char[][], int*, int*, int*);

void print (char[][]);

main(){

char onetoteens[][19] = {"one ", "two ", "three ", "four ", "five ", "six ", "seven ", "eight ", "nine ", "ten ", "eleven ", "twelve ", "thirteen ", "fourteen ", "fifteen ", "sixteen ", "seventeen ", "eighteen ", "nineteen "};

char tys[][9] = {" twenty", " thirty", " forty", " fifty", " sixty", " seventy", " eighty", " ninety"};

char english[50][50];

int num, first, second, third;

read (&num, &first, &second, &third);

cat (onetoteens[][]. tys[][], english[][], &first, &second, &third);

print (english[][]);



}

void read (int *num, int *first, int *second, int *third)
{

printf ("Enter a three digit number: ");
scanf ("%d", num);

*third=*num%10;
*second=*num/10%10;
*first=*num/100;

}

void cat (char onetoteens[][], char tys[][], char english[][], int *first, int *second, int *third) {

strcat (english[50], onetoteens[*first-1]);
strcat (english[50], tys[*second-2]);
strcat (english[50], onetoteens[*third-1]);

}

void print (char enlgish[][])
{

printf ("%s", english);

/*printf("The number entered is: %shundred%s %s", onetoteens[first-1], tys[second-2], onetoteens[third-1]);*/

}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > using an array and passing it to a function (just learning)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway