|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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]);*/ } |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > using an array and passing it to a function (just learning) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|