Triangle source code problem.

i went to the source code page, and downloaded the .zip file for the triangle program. its one of the programs in the first box on the source code page, but when i open it, i cant read the code because this error comes up:

Windows cannot find 'C:\Users\Aaron Silman\Downloads\triangle.zip\triangle.cpp'. Make sure you typed the name correctly, and try again.

then i click the OK box, and this message box comes up

Windows cannot complete the extraction.

The destination file could not be created

why cant i view this code? i am using visual studios 2005. This happens for all the source code i try to download
Last edited on
I think the source code is dead on this site.
Google C++ Triangle or something similar.
closed account (S6k9GNh0)
I have a question. I made a post here ealier and it seems to have been deleted by someone other than me. Was it inappropriate?
The sourcecode downloads work on my computer (I've noticed that it didn't work some time ago but it was fixed after a while)
You just need to unzip the file before viewing in with Visual Studio

if you still have problems, here is trianle.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Program to make a pyramid of characters based on input from user
// Purpose is to examine use of <iomanip.h> and how setw is used
// Created by Gary Paduana
// email : gary3141@home.com
// Written on 4.15.01
 
# include <iostream.h>
# include <iomanip.h>   // library that has the setw output manipulator
 
int main ()
{
 
 char letter;      // letter is the symbol or letter made into a giant triangle
 int width;        // width is how far to go into the center of screen
 int base;         // base is how many symbols are on bottom line
 int a;            // a is how many lines down the triangle is
 int b = 1;        // b is how many symbols are displayed on each line
 int counter = 0;  // counter is how many times the loop executed
 
 cout<<"This program will make a triangle of the symbol entered."<<endl;
 cout<<"It must be an odd number for the triangle to form properly."<<endl; 
 cout<<"If an even number is entered, it will be lowered to the previous odd."<<endl;
 
 
 while(cin)        // This allows the program to loop until the user closes the window
 {
  
  cout<<"Enter a symbol or character."<<endl;
  cin>>letter;
 
  cout<<"Enter the number of characters the base should have."<<endl;
  
  cin>>base;
 
  width = (base / 2) + 5 - counter;    // This is how far into the center it should space until it starts outputting the symbol
                                       // It must first be given a value before it enters the loop
  a = 1;                               // a is how many lines down the triangle is, and natuarally it starts on the first line
 
  while(width > 5)    // It will loop and continue to output the symbol until it reaches 5 spaces from the left margin...
                      // so that everything isn't jammed against the side
  {      
   width = (base / 2) + 5 - counter;   // This is how far into the center it should space until it starts outputting the symbol
   
   cout<<setw(width);  // setw is an output manipulator in the <iomanip.h> library.  this tell the compiler how many lines
                       // to move until it first sends a character to the screen.  It is currently set to move the value of 
                       // "width" spaces to the right before it outputs.
   
   while(b > 0)  // This while loop will continue to output the desired symbol to the current line until it is equal to 1
   {
    cout<<letter;    // outputs the letter or symbol entered
    b--;             // b is decremented so only so many letters are outputted per line
   }
   cout<<endl;       // an endl is used to jump to the next line to output the next part of the triangle
   b = (a * 2) - 1;  // the number of symbols per line is found using this equation
 
   width--;          // the width is decremented so that everything is spaced properly
   b = b + 2;        // b is given 2 more symbols because it is on the next line, and every line has 2 more than the previous
   a++;              // this is how many lines into the triangle it is
   counter++;        // the counter is used to ensure proper spacing done by the width variable
  }
  cout<<endl<<endl;  // endl is used to add some space between each time the program is executed
  b = 1;             // b is returned to 1 because the program started over
  counter = 0;       // counter is returned to 0 because the program started over
 }
return 0;
}
Notice that you may need to change lines 7-8 removing the .h and use std namespace
Last edited on
i tried extracting it and it didnt work, is that the same as unzipping?
Yes, it works fine for me. I'm using 7-zip.
your using a serperate program to unzip, i just right click and hit extract, is that the problem, should i be doing it a different way?
also im using vista
I can extract it using Vista just by dragging the file on another folder
Topic archived. No new replies allowed.