| | |
Help me figure this question
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2007
Posts: 28
Reputation:
Solved Threads: 0
Q. Write a function Stars() whose input are an array of characters(a), the size of the array(n), and a character(ch). This function should replace all occurrences of ch in the array, a, with a star(*), and return the number of times the replacement was made.
So far I have the function prototype
So far I have the function prototype
c Syntax (Toggle Plain Text)
int stars(char a[n], char ch, int n) { }
Last edited by Narue; Mar 26th, 2008 at 9:25 am. Reason: Added code tags
•
•
Join Date: Oct 2007
Posts: 28
Reputation:
Solved Threads: 0
does this look ok?
c Syntax (Toggle Plain Text)
int stars(char a[n], char ch, int n) { int replacenum = 0; int i; for ( i = 0; i < replacenum; i++) { if (a[i] == ch) { a[i] = '*'; } } replacenum = a[n]; return replacenum; }
Last edited by Narue; Mar 26th, 2008 at 12:32 pm. Reason: Added code tags and formatted the code. Do it yourself next time.
![]() |
Similar Threads
- vBulletin mod_rewrite question? (Website Reviews)
- ATI vs. ATI question. (Monitors, Displays and Video Cards)
- google link popularity question (Search Engine Optimization)
- C programming question (C)
- Cannot figure out why I'm getting these Errors (Java)
- Apache Alias Directive... mod_alias question (Linux Servers and Apache)
- T22 s-video and infra red question (Monitors, Displays and Video Cards)
Other Threads in the C Forum
- Previous Thread: Strange crashing in windows, possible memory issues?
- Next Thread: help me in C
| Thread Tools | Search this Thread |
#include * append array arrays asterisks binarysearch calculate changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fflush fgets file fork forloop framework function getlasterror givemetehcodez grade gtkwinlinux hacking histogram inches include incrementoperators input intmain() iso kernel keyboard km license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft motherboard mqqueue number oddnumber odf opendocumentformat opensource overwrite owf pattern pdf performance pointer posix problem probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket socketprograming standard string structures systemcall testing threads turboc unix user variable voidmain() wab whythiscodecausesegmentationfault windowsapi






