| | |
A student that needs your help
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Let's say you put your input in 'acBuffer[]'
:
Or something like that.
cheers Niek
ps. Don't forget to include string.h
:
C Syntax (Toggle Plain Text)
int iCount = 0; for (iCount = strlen(acBuffer); iCount => 0; iCount--) { printf("%s\n", acBuffer); acBuffer[iCount] = '\0'; }
Or something like that.
cheers Niek
ps. Don't forget to include string.h
Last edited by niek_e; Oct 11th, 2006 at 10:33 am.
•
•
Join Date: Oct 2006
Posts: 5
Reputation:
Solved Threads: 0
•
•
•
•
Let's say you put your input in 'acBuffer[]'
:
C Syntax (Toggle Plain Text)
int iCount = 0; for (iCount = strlen(acBuffer); iCount => 0; iCount--) { printf("%s\n", acBuffer); acBuffer[iCount] = '\0'; <============it doesnt work }
Or something like that.
cheers Niek
ps. Don't forget to include string.h
(i forgot to mentioned that i need this on C)!!!!!
this is my prog so far:
#include <stdio.h>
#include <string.h>
main(){
char acbuffer[50];
int icount=0;
clrsrc();
printf("Enter Any Word: ");
scanf("%s", &acbuffer);
strlen(acbuffer);
for (icount=strlen(acbuffer); icount>0; icount--)
{
printf("%s\n", acbuffer);
acbuffer[icount]='0'; <======= right here i think need to decreased my word some how ..
}
getche();}
Need to decrease any word. EX. Hello then i will be Hell, Hel, He and so on until i doenst have any letters on it then the prog is terminated.
•
•
Join Date: Oct 2006
Posts: 5
Reputation:
Solved Threads: 0
nieke can you tell me what version your turbo c and where did you i can find download that cause im using version 2.1 and stdio.h doesnt work here...
here is an ex of a prog that my teacher gave to us but it doesnt work in version 2.1
#include <stdio.h>
#include <conio.h)
voidmain(){
clrsrc();
int a, i;
for (a=5; a>0; a--)
{
for (i=a; i<5; i++)
printf("x" );
printf("y\n");
}
getche();}
thanks for your reply i really need this or i will fail my class..
here is an ex of a prog that my teacher gave to us but it doesnt work in version 2.1
#include <stdio.h>
#include <conio.h)
voidmain(){
clrsrc();
int a, i;
for (a=5; a>0; a--)
{
for (i=a; i<5; i++)
printf("x" );
printf("y\n");
}
getche();}
thanks for your reply i really need this or i will fail my class..
The latest version of the compiler can be downloaded from here:
http://www.borland.com/downloads/download_cbuilder.html
Your prev code was full of non standard functions. Dont use functions like
http://www.borland.com/downloads/download_cbuilder.html
C Syntax (Toggle Plain Text)
#include <stdio.h> int main () { int a, i; for (a=5; a>0; a--) { for (i=a; i<5; i++) { printf("x" ); } printf("y\n"); getchar () ; }
Your prev code was full of non standard functions. Dont use functions like
clrscr ( ) and dont use non standard headers like #include <conio.h> I don't accept change; I don't deserve to live.
THe code which you have attempted, makes use of "scanf" for accepting string or char data which normally is not advised since it leaves the input stream dirty and which will cause behaviour which u had not expected.
Better use the technique which i have used while accepting char data and it will always work like a breeze.
Also you have used only one for loop to implement your logic which is not correct since you normally need one for controlling the number of chars to be printed and the second one to actually print characters.
Try somehting like this:
PS:: And by the way my name is not Painkilller, its ~s.o.s~
Better use the technique which i have used while accepting char data and it will always work like a breeze.
Also you have used only one for loop to implement your logic which is not correct since you normally need one for controlling the number of chars to be printed and the second one to actually print characters.
Try somehting like this:
C Syntax (Toggle Plain Text)
int main() { int i = 0, j = 0 ; char buffer[BUFSIZ] = {'\0'} ; printf ("Enter the string you want to display: ") ; fgets (buffer, BUFSIZ, stdin) ; if (buffer[ strlen (buffer) - 1 ] == '\n') buffer[ strlen (buffer) - 1 ] = '\0' ; for ( i = strlen (buffer) ; i > 0; --i) { for ( j = 0; j < i; ++j) { putchar (buffer [j]) ; } putchar ('\n') ; } return 0 ; }
PS:: And by the way my name is not Painkilller, its ~s.o.s~
Last edited by ~s.o.s~; Oct 11th, 2006 at 2:24 pm.
I don't accept change; I don't deserve to live.
C Syntax (Toggle Plain Text)
int main() { int i = 0, j = 0 ; char buffer[BUFSIZ] = {'\0'} ; printf ("Enter the string you want to display: ") ; fgets (buffer, BUFSIZ, stdin) ; for ( i = strlen (buffer) ; i > 0; --i) { buffer[i] = '\0'; printf("&s\n", buffer); } return 0 ; }
![]() |
Similar Threads
- calculate the grades for a student using if..else statements. (Java)
- Student Suspended for using PHP!! (IT Professionals' Lounge)
- JAVA program help (Student/Grades) (Java)
- Who can help a student with her exams in Java?? (Java)
- Quiet student (Computer Science)
- Querying database records (Visual Basic 4 / 5 / 6)
Other Threads in the C Forum
- Previous Thread: writing a program
- Next Thread: compiling error
| Thread Tools | Search this Thread |
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic fflush file floatingpointvalidation fork frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide inches infiniteloop initialization interest kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql odf open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer pointers posix power probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape single socketprograming socketprogramming stack standard strchr string strings structures suggestions systemcall test testautomation unix urboc user voidmain() wab win32api windows.h






