Member Avatar for iamthwee

Hi guys i have abadoned my ofther assinement becoz it woz 2 hard to learn classes and i stil need 2 learn a function proberly.my teacher said if i not understand functions yet then i wait to learn classes. tank u again 4 your help. Now i need to do another one and this time it is about file go in and out.

what i hav 2 do...

Create a moving avatar using fstreams.

Your assignment is to create a html file that animates three pictures saved in your current directory.

You will be required to do these things. You must create your html file so that it is compatible with internet explorer. You must give the user various options to control:-

1. The number of slides
2. Optional links for each slide if any
3. The number of cycles
4. The delay between each slide.

Once the user has entered these options your program will create a
slideshow in html format.

(hints)
The html code for a slideshow can be found on the internet. You should read the source code in from a file and write it to a html file.

<< moderator edit: fixed [quote][/quote] tags >>

Member Avatar for iamthwee

here it is, is it any good.

/*========================================
  A program which creates a moving Avatar
  
  by Iamthwee, all rights reserved
  ========================================*/
  
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    int slides,cycles,delay;
    
    cout<<"       \nHow many slides are there eg. (4):";
    cin>>slides;
    
    
    cout<<"       \nHow many cycles do you want eg. (10):";
    cin>>cycles;
    cout<<"       \nEnter your delay in ms eg.(500):";
    cin>>delay;
    fstream f_pointer;
    f_pointer.open("avatar.html",ios::out);
    char ch;
    ifstream read("erm.txt");
    while(read.get(ch))   
    {
        if(ch=='@')
        {
            for (int i=0; i<slides; i++)
            {
                f_pointer<<"ultimateshow["<<i<<"]=['../../Desktop/zipped/pic"<<i<<".bmp', '', '']"<<endl;
            }
        }
        else if(ch=='©')
        {
            f_pointer<<cycles;
        }
        else if(ch=='#')
        {
            f_pointer<<delay;
        }              
            
        else
        {
        f_pointer<<ch; 
        }             
    }
    read.close();
    f_pointer.close();
    cout<<"Your html has been created"<<endl;
    cin.get();
    cin.get();
    return 0;
}    

//ultimateshow[0]=['../../Desktop/zipped/pic0.bmp', '', '']

erm.txt

<html>

<head>

</head>

<body>
<script type="text/javascript">

// Flexible Image Slideshow- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use

var ultimateshow=new Array()

//ultimateshow[x]=["path to image", "OPTIONAL link for image", "OPTIONAL link target"]

@

//configure the below 3 variables to set the dimension/background color of the slideshow

var slidewidth="0px" //set to width of LARGEST image in your slideshow
var slideheight="0px" //set to height of LARGEST iamge in your slideshow
var slidecycles="©" //number of cycles before slideshow stops (ie: "2" or "continous")
var randomorder="no" //randomize the order in which images are displayed? "yes" or "no"
var preloadimages="yes" //preload images? "yes" or "no"
var slidebgcolor='white'

//configure the below variable to determine the delay between image rotations (in miliseconds)
var slidedelay=#

////Do not edit pass this line////////////////

var ie=document.all
var dom=document.getElementById
var curcycle=0

if (preloadimages=="yes"){
for (i=0;i<ultimateshow.length;i++){
var cacheimage=new Image()
cacheimage.src=ultimateshow[i][0]
}
}

var currentslide=0

function randomize(targetarray){
ultimateshowCopy=new Array()
var the_one
var z=0
while (z<targetarray.length){
the_one=Math.floor(Math.random()*targetarray.length)
if (targetarray[the_one]!="_selected!"){
ultimateshowCopy[z]=targetarray[the_one]
targetarray[the_one]="_selected!"
z++
}
}
}

if (randomorder=="yes")
randomize(ultimateshow)
else
ultimateshowCopy=ultimateshow

function rotateimages(){
curcycle=(currentslide==0)? curcycle+1 : curcycle
ultcontainer='<center>'
if (ultimateshowCopy[currentslide][1]!="")
ultcontainer+='<a href="'+ultimateshowCopy[currentslide][1]+'" target="'+ultimateshowCopy[currentslide][2]+'">'
ultcontainer+='<img src="'+ultimateshowCopy[currentslide][0]+'" border="0">'
if (ultimateshowCopy[currentslide][1]!="")
ultcontainer+='</a>'
ultcontainer+='</center>'
if (ie||dom)
crossrotateobj.innerHTML=ultcontainer
if (currentslide==ultimateshow.length-1) currentslide=0
else currentslide++
if (curcycle==parseInt(slidecycles) && currentslide==0)
return
setTimeout("rotateimages()",slidedelay)
}

if (ie||dom)
document.write('<div id="slidedom" style="width:'+slidewidth+';height:'+slideheight+'; background-color:'+slidebgcolor+'"></div>')

function start_slider(){
crossrotateobj=dom? document.getElementById("slidedom") : document.all.slidedom
rotateimages()
}

if (ie||dom)
window.onload=start_slider

</script>

<p style="font: normal 11px Arial">&nbsp;</p>
</body>

</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.