Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-07-2006, 11:44 PM   #1 (permalink)
js2006
Recruit
 
Join Date: Oct 2006
Posts: 19
js2006 is on a distinguished road
Post strings

how would i print a string say

Circular in a circle format , like as a function

Code:
Output :

Enter a string:
circular

String in circular order:

circular
ircularc
rcularci
cularcir
ularcirc
larcircu
arcircul
rcircula
js2006 is offline   Reply With Quote
Old 11-08-2006, 01:17 AM   #2 (permalink)
js2006
Recruit
 
Join Date: Oct 2006
Posts: 19
js2006 is on a distinguished road
using a char pointer and char array !!
js2006 is offline   Reply With Quote
Old 11-08-2006, 02:00 AM   #3 (permalink)
js2006
Recruit
 
Join Date: Oct 2006
Posts: 19
js2006 is on a distinguished road
something what i done

Code:
#include<iostream>
#include<stdlib.h>
using namespace std;
main()
{
char *ptrA;
char a[9];
a[0] = 'c';
a[1] = 'i';
a[2] = 'r';
a[3] = 'c';
a[4] = 'u';
a[5] = 'l';
a[6] = 'a';
a[7] = 'r';
a[8] = '\0';
ptrA = a ;
cout << ptrA << "\n";
}
js2006 is offline   Reply With Quote
Old 11-08-2006, 02:13 AM   #4 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
I believe you want the modulus operator '%'
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 11-08-2006, 01:21 PM   #5 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
I'm willing to post a solution but hey...
Did you know there are just about a million ways to do it???
If you can't figure it our by logic, then use your imagination!
Demonstrate some effort I'd say. Wouldn't be fair to post a few algorithms already.
__________________
Valmont is offline   Reply With Quote
Old 11-08-2006, 01:41 PM   #6 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
I'd be more than willing to help with a solution, but as Valmont says, theres several ways to do it. One could be very intuitive, given teknos advice, another could be extremly overkill, taking part in your char pointer request...
Start by thinking of the array as a queue, then think of a simple loop to go through that queue, then considder the modulus operator in combination with the length of the array, then you might be onto one solution which would work, next, do the same with the string as a char pointer (where you'd query the address location) then think of a way to know, when that reaches the end of the array, then think of a loop, which would wrap around, once the end is met, then you'd might be onto a second solution, which uses a char pointer reference...

Then design a seperate string class, which has its own std::ostream << operator, which would circle the string once, then think of a.... Nah, that would simply be too much overkill...
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 11-08-2006, 01:47 PM   #7 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Things need to be rotated. So consider it a "rotational problem" for example.
Cool... we have "search" feature on this board .
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
qsort() fails on an array of char* strings fp_unit Standard C, C++ 1 01-28-2006 05:15 PM
Is it necessary to use strings for this assignment? ZimbuTM Java 3 10-19-2005 06:20 PM
Looping search strings. phill2000star PHP 4 07-18-2005 05:37 PM
New Tutorials: ASP Strings, and Visual Studio/VB.NET sde Code Newbie News 0 03-25-2004 07:37 PM


All times are GMT -8. The time now is 03:33 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting