473,320 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How do I write a programme to reverse the words in a sentence?

suppose a string is there"pavani is very good"
i want to print in reverse like"good very is pavani"
i am able to reverse like this "doog si yrev inavap"
for(int i=strlen(str); i>0i--)
printf("%s",str[i];
}

how can i print in above order
May 19 '07 #1
1 2041
AdrianH
1,251 Expert 1GB
suppose a string is there"pavani is very good"
i want to print in reverse like"good very is pavani"
i am able to reverse like this "doog si yrev inavap"
for(int i=strlen(str); i>0i--)
printf("%s",str[i];
}

how can i print in above order
A simple way would be to use strtok to get all of the words (storing them using a char * array) and then printing them out in reverse order. One drawback would be that it would be limited to the max size of your array unless you use a vector.


Adrian
May 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Matt | last post by:
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
7
by: HumanJHawkins | last post by:
Hi all, I have a table of text and associated data. I want to break apart the text into individual words, yet retain the data in other columns. For example: Sentence: Chapter:...
8
by: vijay | last post by:
Hello, As the subject suggests, I need to print the string in the reverse order. I made the following program: # include<stdio.h> struct llnode { char *info;
0
by: PLENI SELENE | last post by:
HOW TECHNOLOGY MOVES FROM TALK TO ELECTRONIC DEVICES TO SPEAK GOOD SPANISH! Would you Like To Know How The Electronic Devices Understand When You Talk to Them, And How It Works To...
6
by: gk245 | last post by:
Basically, i want to make a function that will receive a sentence or phrase, and count its words. It would start like this (i think): #include <stdio.h> int count ( char sentence ) {...
14
by: Jeroen | last post by:
Hi all, I've got a question about writing a library. Let me characterize that library by the following: * there is a class A which is available to the user * there is a class B that is used...
1
by: arnuld | last post by:
this is "word counting" example programme from K&R2 section 1.5.4. it runs without any error/warning but does not work properly, i.e. the OUTPUT 1 should be: NEWLINES: 1 WORDS: 1 CHARs: 5
0
by: swapnil6485 | last post by:
Write a script that prompts you for a sentence, and tells you the number of characters in the sentence, the number of words, and prints the sentence in reverse order.
1
by: Diva | last post by:
Hiya can anyone help me, I am attempting to reverse a stack programme and have come up with void reverse(int stack, int *top) { int temp ; for (int i=0; i <*top;i++){ ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.