vijayan121 1,152 Posting Virtuoso

you can't deactivate precision control. the precision is initially 6 and is always used for floating point (and never for any other type). so you could either make angle an int you can also write

cout << "sin(" << angle << ") = " << fixed << showpoint << setprecision(4) << sin(angle) << endl ;
cout << noshowpoint << setprecision( 0 ) << angle ;

or

cout << "sin(" << angle << ") = " << fixed << showpoint << setprecision(4) << sin(angle) << endl ;
cout << resetiosflags( ios::fixed | ios::showpoint ) <<  angle ;
vijayan121 1,152 Posting Virtuoso

well, if you just need to count the number of words that end in punctuation, you do not need to store it in an array or a vector first. assuming that words are whitespace separated, read word by word into a std::string till there is nothing more.

std::string word ;
while( std::cin >> word )
{
  // process it
}

to get the last character of the word

if( !word.empty() )
{
   char last_char = word[ word.size()-1 ] ;
   // check if it a punctuation, if yes increment a count
}

to check if a char is a punctuation in the input locale, use std::ispunct (#include <cctype>)

const std::locale& input_locale = std::cin.getloc() ; 
if( std::ispunct( last_char, input_locale ) ) ++count ;

if you also need to store the words read for access later, add each word to a std::vector<string>

vijayan121 1,152 Posting Virtuoso

> VB will teach you a lot of things that are common to nearly all languages,
> such as data types (integers, strings etc), loops, and file systems
true.
perhaps you could learn a language which is radically different from the mainstream ones (which are all alike in many respects). you could then learn concepts and techniques which would make you a better programmer, no matter what language you eventually decide to program in.
like lisp. to get a peep at what it loks like, see
http://www.ibm.com/developerworks/java/library/j-cb02067.html
and if what you see interests you,

> where can i find a site to teach myself from?
there are very, very many. eg.
http://www.gigamonkeys.com/book/
http://mypage.iu.edu/~colallen/lp/
http://www.mars.cs.unp.ac.za/lisp/

and this is a lisp implementation which works all comon machines: http://clisp.cons.org/

vijayan121 1,152 Posting Virtuoso

JIT Debugging is an abbreviation for just-in-time debugging. all that it does is allow a debugger to be attched to a process which was not running under a debugger so far.
see http://msdn2.microsoft.com/en-us/library/ms679295(VS.85).aspx

> some system file on the computer will take care of this Exception.
no one will take care of this exception if you turn jit debugging off. your program will be terminated and a diagnostic dump of the state of the process at the time it was terminated would be generated. if you have enabled a minidump (or a full dump) to be generated, you can later do a post-mortem debug with WinDbg or (somewhat limited) Visual Studio.
http://msdn2.microsoft.com/en-us/library/bb204861.aspx

vijayan121 1,152 Posting Virtuoso

this is not a valid c++ program (size of a c-style array must be a constant known at compile time).

int main()
{
   // ...
   int row_size = 1 ;
   // ...
   int new_row[row_size*4] ; // error: ISO C++ forbids 
                  // variable-size array 'new_row'
   // ...
}

this is (size of a vector<> can be decided at run time).

#include <vector>
int main()
{
   // ...
   int row_size = 1 ;
   // ...
   std::vector<int> new_row(row_size*4) ; // fine
   // ...
}

use a vector instead, it behaves like a resizable java array with value semantics.

vijayan121 1,152 Posting Virtuoso

> I need actually a simple library that i can write c++ program to retrieve information
> from xml file. then integrate this program into whole c++ system.
> so it requires just simple functions.
> I have found these 3 libraries. just dont know how to decide. maybe i must try them out first.

i think you should stick to TinyXml++. of the three, it is the easiest to use. and should meet your requirement more than adequately.

vijayan121 1,152 Posting Virtuoso

> here my program crashes.............may be its bcoz the heap memory is less
yes. to specify a larger process default heap size for your executable image, use the /HEAP linker switch. http://msdn2.microsoft.com/en-us/library/f90ybzkh.aspx
to allocate 468 MB of memory, the heap is not a good choice. use VirtualAlloc instead. http://msdn2.microsoft.com/en-us/library/aa366887(VS.85).aspx

vijayan121 1,152 Posting Virtuoso

the c++ standard only specifies the performance requirements: for insert, erase and find
this is O( log N ). to meet this requirement, any tree implementation must be (reasonably) balanced at all times.

vijayan121 1,152 Posting Virtuoso

> The FREE XML parser must come with both DOM and SAX mode
1. xerces (apache license) http://xerces.apache.org/xerces-c/
2. libxml (MIT license) http://www.xmlsoft.org/
perhaps with libxml++ (viral LGPL) http://libxmlplusplus.sourceforge.net/

vijayan121 1,152 Posting Virtuoso
#include <iostream>
#include <iomanip>

int main()
{
   // std::cout << std::setiosflags(std::ios::fixed) 
   //        << 22.6 << '\n' ;
   std::cout << std::fixed << 22.6 << '\n' ; // easier
   
   // std::cout << std::setiosflags(std::ios::hex) 
   //        << 34 << '\n' ;
   std::cout << std::hex << 34 << '\n' ; // easier
}
vijayan121 1,152 Posting Virtuoso

> easy to learn, light -weight...
TinyXml++ perhaps? http://code.google.com/p/ticpp/

vijayan121 1,152 Posting Virtuoso

Dev-C++ on windows uses the Mingw port of GCC by default.
MinGW uses native Windows DLLs for everything; code compiled with MinGW will use standard Microsoft runtime libraries such as MSVCRT.DLL.

Dev-C++ can also be used in combination with Cygwin and this is what you need to do if you want to use unix-like libraries and headers. Cygwin relies on a Unix emulation layer, code compiled with Cygwin uses the standard GNU runtime library (glibc) with an emulation of Unix system calls like fork, and semantics like mount points, pipes and path separators.

however, Cygwin has a restrictive (viral) license, whereas MinGW is available under a free license.

vijayan121 1,152 Posting Virtuoso
int eig( int num )
{
  if( num<10 ) return num;
  else return eig( eig( num/10 ) + (num%10) ) ;
}

cool!
though you spoiled it by void main() and #include<iostream.h>

vijayan121 1,152 Posting Virtuoso

String s2 = <some_expression> ; initializes one String with another String (copy construct). if <some_expression> is not a String, it must be implicitly convertible to one. it is semantically like int i = <some_expression> ; initializes one int with another int. if <some_expression> is not an int it is implicitly converted to one.
so, to be able to write String s2 = "Whatever"; requires a non-explicit constructor and an accessible copy constructor ( 'even if it may not be called' ).
to write String s2(" Whatever" ) ; or String s2 = String( "Whatever" ) ; does not require the constructor to be non-explicit.

vijayan121 1,152 Posting Virtuoso

> Without using an array (all my data types are not the same)
there are two ways to solve this. either use a struct which collects information about one cad drawing in one place or use multiple arrays; one array for each part of the information. since i'm not sure that you are familiar with struct or class , let us look at using many arrays.

enum { MAX_DRAWINGS = 500 }; // maximum possible
int num_drawings = 0 ; // actual number
int serial_number[ MAX_DRAWINGS ] ;
int revision_number[ MAX_DRAWINGS ] ;
int date_of_revision[ MAX_DRAWINGS ] ;
char department[ MAX_DRAWINGS ] ;

for input of information, we write a loop of this kind:

int i = num_drawings ;
for(   ; i < MAX_DRAWINGS ; ++i )
{
   // get serial number, put it in serial_number[i]
   // get revisionnumber, put it in revision_number[i]
   // get date of revision, put it in date_of_revision[i]
   // get department, put it in department[i]
   // break out of loop if end of user input
}
num_drawings = i ;

at the end of this serial_number[15] will contain a drawings serial number (say 1382),
revision_number[15] will be its revision number,
department[15] will be its department etc.

to get information about a drawing with a specific serial number,
a. get the position by searching in the array serial_number
b. get the other information from the same position in the other arrays

for( int pos = 0 ; pos …
vijayan121 1,152 Posting Virtuoso

> So, if the user inputs 1234 for num, can I make a structure
> where the name equals the value of num, i.e. Serialnumber 1234?

1234 is not a valid C++ identifier. but ven for a valid identifier ( like sn_1234 ),

the short answer to your question is no.
names (identifiers) are compile-time entities. they are used by the compiler at compile-time. identifiers need to be specified at the time you write your code.
modifiable values are run-time entities. eg. a value supplied by the user are available only when the program (that you had compiled earlier) executes.

a longer answer would be: it is possible to get the effect you are looking for by writing a source code generator and dynamically compiling and executing the generated source code. (an explanation of how to do this should go here. but, since you are right now just beginning to learn C++, do not even consider this to be a possibility.)

why is it that you are trying to do this (want to name individual incarnations of a struct by numeric information supplied by the user)? if you posted
a. what is the program that you are trying to write supposed to do? and
b. where are you encountering a problem in writing it?
there would be many here who could help. and you might discover that the solution to the real problem is surprisingly simple.

vijayan121 1,152 Posting Virtuoso

> I think the issues I'm getting are revolving around pointer issues ...
there are several issues. let us take them one by one.

class structure
{

    public:
      string _word;
      vector<int> _indices;
      // ...
      structure() ; 

      // passing a string using const reference is more efficient;
      // we avoid the need to make a copy of a string
      structure( const string& word ) ;
      /// ...
      void putpage( int number ) ;
      bool haspage( int number ) ;
      // ....
};

these lines in the constructor(s) do nothing useful.

{
  // creates a string which is destroyed on return
  string _word;
 
  // this merely declares a function named _indices
  vector<int> *_indices();
}

both the string and the vector have default constructors which would initialize them correctly. so the default constructor needs to be just

structure::structure() 
{ /* default initialization for _word, _indices */ }

in a constructor, we could also initialize a member in a non-default way. eg.

structure::structure( const string& word ) : _word( word ) 
{ 
  // member _word initialized with word	 
  // default initialization for _indices 
}

to add a number to the vector indices

void structure::putpage( int number ) 
{ _indices.push_back( number ) ; }

to check weather a number is present in the vector indices, you could iterate through the vector looking for the number, or (easier) use the algorithm std::find

#include <algorithm>
bool structure::haspage( int number ) 
{ 
  return std::find( _indices.begin(), _indices.end(), number )
                != _indices.end() ; …
vijayan121 1,152 Posting Virtuoso

> What type of syntax do I need to set my class to be of type comparable?

nothing at all; just declare and implement the comparison operator(s). in

template<class Comparable>
class BinarySearchTree;

Comparable is just a place holder; the above is equivalent to

template< class T >
class BinarySearchTree;

and your structure could be

class structure
{
public:
  string _word;
  vector<int> _indices;
  structure();
  structure(string word);
  structure(string word, int number);
  void putpage(int number);
  bool haspage(int number);
  bool operator< (const structure & rhs) const ; // this should be a selector

  friend class BinarySearchTree<structure>;
};

this is how you could instantiate a BinarySearchTree of structures.

BinarySearchTree<structure> the_search_tree ;

and this would declare a function taking a binary search tree of structures as an argument

void function( BinarySearchTree<structure>& tree ) ;
vijayan121 1,152 Posting Virtuoso

> The error message probably means that you should have a statement of some sort between each if and each else.

>> No it doesn't. It is legal to have nothing in the TRUE position of an if

yes, it does. having nothing is not legal C++. however, the statement may be
a null statement ( just a ; ) or an empty compound statement ( {} ).

vijayan121 1,152 Posting Virtuoso
#include <cliext/vector>
using namespace cliext ;

// ...
// create an empty vector
cliext::vector< String^ >^ Box1 = gcnew cliext::vector< String^ >;

// this will not work; there is no space in the vector
// Box1[0] = comboBox1->SelectedItem->ToString();

// this would; make space for the element
Box1->push_back( comboBox1->SelectedItem->ToString() ) ;

// fine; Box1 now has one element and Box1[0] retrives it
String^ path = "C:\\Glob\\Groups\\" + Box1[0] + ".txt";
// however Box1[1] is an error here; there is only one element right now.

it would be a good idea to give your variables more meaningful identifiers than ComboBox1, Box23 etc. like file_names_combobox or select_file_combo instead of ComboBox1.

vijayan121 1,152 Posting Virtuoso

it would be easier (and also more efficient) if you use a cliext::vector<> instead of a std::vector<> note: requires VC++ 9 (2008)

#include <cliext/vector>
using namespace cliext ;

// ...
{
  // ...
  vector< String^ >^ vec = gcnew vector< String^ > ;
  vec->push_back( comboBox1->SelectedItem->ToString() ) ;
  String^ Box1 = vec[0] ;
  // ...
}
vijayan121 1,152 Posting Virtuoso

> What i expect after restore a network connection it should work proper
the problem is that the FILE structure that is being passed to fprintf is no longer usable. it contains an operating system file descriptor (handle) which is not valid any more. you really do not need to restart the application. instead you could just close the file and reopen it afresh. (perhaps have a background thread waiting on an event to do this at the right time).

vijayan121 1,152 Posting Virtuoso

> How is that the "My Name.." bit, which I believe to be a const char* or string literal
> be somehow resolved to a String object for the purposes of the function.
the String class has a (non-explicit) single argument constructor which takes a const char * . this also acts as an implicit conversion operator.
an anonymous String is constructed and passed to String operator+(const String &s1, const String &s2); > Originally, my prototypes were ...
these are just fine and for something like s2 = "My name is " + s3; is more efficient.
the creation of an anonymous temporary String object is avoided.

vijayan121 1,152 Posting Virtuoso

> How do I write three different calling statement to the MyFunction function
> without declaring additional variable.
what kind of question is this? the second parameter must be I. there are an infinite number of ways in which the first parameter could be a bool.

MyFunction ( B, I ) ;
MyFunction ( I, I ) ;
MyFunction ( D, I ) ;
MyFunction ( D>I, I ) ;
MyFunction ( B && (D==I), I ) ;
MyFunction ( I+I, I ) ;
// ...
vijayan121 1,152 Posting Virtuoso

Gee, maybe you should try that first next time... :icon_rolleyes:

Gee, maybe i should look up ISO/IEC 14882 first before i write main the next time... :icon_rolleyes:

vijayan121 1,152 Posting Virtuoso

could you tell me why? (i know i'm missing something obvious, but can't see what)
[edit]
got impatient ant tried it on a compiler. seems to work alright.
[/edit]

vijayan121 1,152 Posting Virtuoso
Func1(d1,c), Func2(d1,d2), Func3(d1==d2) ;

if order of calling does not matter, also

Func1( Func3( Func2(d1,d2) ), c ) ;
vijayan121 1,152 Posting Virtuoso

use the sequencing (comma) operator

vijayan121 1,152 Posting Virtuoso

> Only in MS-Windows and MS-DOS do we run into trouble with text mode seeks
> due to the two-byte line terminators.
> I have no idea how it works on non-English file systems, presumably the same.
in reality, all we would want is to use tellg to mark a position in an fstream and use seekg to get to that precise location sometime later. this will always work correctly on all streams. problems arise with seek on fstreams (in windows (text mode) or locales using MBC character sets) if we seek to a position that was not earlier returned by a tell. for example, this code (VC++,windows; locale names are not portable) would always work correctly; we are not seeking to arbitrary positions.

#include <iostream>
#include <fstream>
#include <string>
#include <locale>
using namespace std ;

int main()
{
 { ofstream temp("a.txt") ; } // create a new file

 const locale german ( "german" );
 fstream file( "a.txt", ios::in|ios::out ) ;
 file.imbue( german ) ;
 file << "some \n random \n lines\n\n" ;
 
 fstream::pos_type namepos = file.tellg() ;
 file << "name string" << '\n' << '\n' ;
 
 fstream::pos_type phonepos = file.tellg() ;
 file << 12345678 << '\n'<< '\n' << '\n' ;
 
 fstream::pos_type addresspos = file.tellg() ;
 file << "address string\n" ;

 file << "a few more \n\n random \n lines\n\n\n" ;

 string str ;
 cout.imbue( german ) ;

 file.seekg( namepos ) ;
 getline( file, str ) ; 
 cout << str << '\n' ;

 file.seekg( addresspos ) …
vijayan121 1,152 Posting Virtuoso

> file.clear() and file.seekg(...) shouldn't work correctly either?
>If that's the case, is there any way I can return to the beginning of the file without opening it in binary?
file.clear() will work in all cases.
file.seekg(...) will work in all cases if you seek to the beginning of the file.
otherwise, if the streampos that you use for the seek wasn't one returned by an earlier tellg on the same stream/filebuff, all bets are off. c++ throws in locale dependent character code translation, even when the char_type of the stream is just a char. you migh end up on the second byte of a multibyte character sequence or on the lf of a cr-lf sequence.
if you open a file stream (where the char_type of the stream is just a char) in binary mode and imbue the "C" locale, which will always result in a constant character width equal to one, you can seek to an arbitrary position.

vijayan121 1,152 Posting Virtuoso

> I also found an example at cplusplus.com that uses the file pointers on a .txt file (in addition to a binary file), here's their example ...
AARGH!
1. stream::tellg() returns an streampos, which isn't guaranteed to be convertible to an integral type
2. even if streampos is convertible to an integral type, there's no guarantee that the numeric value of this type has any real significance (eg. high order bits contain the sector number, low order bits the offset in the sector).
3. even if it represents some numerical offset within the system, it isn't guaranteed to fit in a long.
4. subtracting one streampos from another gives a streamoff. streamoff is some integral type, but will not necessarily fit in a long.

even if streampos and streamoff are long values, there would be problems when multi-byte encodings are involved.
even if the locale imbued by the stream is the classic "C" locale with single byte encoding, there would be problems because of escape sequence translations during input/output.

all that seekg on an fstream does is call filebuf::seekpos or filebuf::seekoff. and the standard says:
"If the position has not been obtained by a previous successful call to one of the positioning functions (seekoff or seekpos) on the same file the effects are undefined."

try the following on a windows machine (with single-byte ascii encoding for the default locale):

#include <fstream>
#include <iostream>
#include <string>
int main() …
vijayan121 1,152 Posting Virtuoso

> How would I go about locating a file on the computer, and using it in my application?
no really portable way of doing it (if you want a fast search).
you could do this on unix system( "/usr/bin/locate 'file_name_glob' > files_found.txt" ) ; and then pickup the complete path(s) from files_found.txt. this assumes that the locate database is recomputed periodically. /usr/bin/find would always work; but could be quite slow.
on windows, you could use the indexing service api.
on machines where google desktop search + sdk is installed, you could also use its api.

vijayan121 1,152 Posting Virtuoso

the problem with the code using unsigned it is that nowhere in the c++ standard does it say std::numeric_limits<unsigned int>::max() >= 2^32 - 1 or for that matter, std::numeric_limits<unsigned int>::radix == 2 or std::numeric_limits<unsigned int>::digits >= 32 .
so the code may fail for some input values on some implementations.

the code that was accepted is neither ISO C++ nor ANSI C. neither talks about a type long long.
the C99 standard introduced the long long int type ( to be an integral type with at least 64 bits) and it is a long-supported extension by almost all compilers. (C++0x adds this type as well as unsigned long long as fundamental types). by now, long long int (abbreviated as long long) has become a de facto standard (it is de jure only in C99). which is probably why it was accepted.

vijayan121 1,152 Posting Virtuoso

the file is not in a good state after your loop executes file.eof() == true clear the eofbit first.

file.clear() ;
  file.seekg( 0, std::ios::beg ) ;

the seekg you are doing is ok because you are seeking to the beginning of the file. for a seekg to some non-zero offset (or a seekg from the end) to work reliably (portably), the file has to be opened in binary mode.

vijayan121 1,152 Posting Virtuoso
int main()
{ 	   
   	
   int numbers[4];
   int i;
    
    ifstream streamin;
   
    streamin.open("input.txt");
    for(i=0;i<4;i++)
    {
       streamin >>  numbers[i] ;
    }

    // what is the value of i at this point?
    cout << numbers[i];

    streamin.close();
}
vijayan121 1,152 Posting Virtuoso

> what should be coming next in this list
> Hello world>>data types>>conditional execution>>C-style arrays>>C-style
> strings>>loops>>functions>>structs>>classes
templates, perhaps?

> That book is very costly, and not available in any library near me
Thinking in C++ 2nd Edition by Bruce Eckel is pretty ok and is available as a free e-book.
http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html

vijayan121 1,152 Posting Virtuoso

you may want to have a look at ftp://ftp.ox.ac.uk/pub/wordlists/dictionaries/ and if you are interested in american (gotta and the like), ftp://ftp.ox.ac.uk/pub/wordlists/american

vijayan121 1,152 Posting Virtuoso

wouldn't /usr/share/dict/words suffice? in FreeBSD, this has words from Webster's 2nd International dictionary (quite a few words).

>cat /usr/share/dict/words | wc -lw
  235882  235882

if you are not on unix, download from http://www.freebsd.org/cgi/cvsweb.cgi/src/share/dict/web2

vijayan121 1,152 Posting Virtuoso
#include <iostream>
#include <sstream>
#include <iomanip>

enum { PRECISION = 2, WIDTH = 11, FILLER = ' ' } ;
inline void print_aligned( double value )
{
  // put $ddd.dd into a string
  std::ostringstream stm ;
  stm << '$' << std::fixed << std::setprecision(PRECISION) 
       << value ;
  // print the string in a right justified field
  std::cout << std::setw(WIDTH) << std::setfill( char(FILLER) )
            << std::right << stm.str() << '\n' ;
}

int main()
{
  double x=12.34, y=567.894, z=6.38215 ;
  print_aligned(x) ;
  print_aligned(y) ;
  print_aligned(z) ;
}
vijayan121 1,152 Posting Virtuoso

yes. something like

int max_so_far = array[0] ;
for( int i=1 ; i<num_elements ; ++i )
{
  // if the element in question is greater than max_so_far, make 
  // max_so_far equal to that element
}
// max_so_far now contains the value of the largest element in the array
henpecked1 commented: V was very patient and very helpful +1
vijayan121 1,152 Posting Virtuoso

yes. the problem is the same. fill the array that is passed to the function, not something else.
your main would look like:

// ...
const int N = 24 ;
int what_ever_you_want_to_call_it[N] ; // array of temperatures
gettemps( what_ever_you_want_to_call_it, N ) ;
double avg = averagetemp( what_ever_you_want_to_call_it, N ) ;
// ...
vijayan121 1,152 Posting Virtuoso

in your code,

double averagetemp( int temp[], int numtemp)
{
sum = 0.0;
for (i = 0; i < Count; i++)
   sum = sum + hourlytemps[i];

if (count > 0)
   return sum / count;
else
   return 0.00;
}

you are using some other array than the one passed to the function. the array (for which average is to be determined is temp not hourlytemps. and the number of elements are numtemp, not count

> So does this mean my prototypes are wrong in the header?
no. the prototypes are correct. the array called temp in the prototype is the same array that you want to call hourlytemps. and perhaps you are under the impression that these are two different arrays. giving rise to the confusion.

vijayan121 1,152 Posting Virtuoso
double averagetemp( const int hourlytemps[], int numtemp)
{
  // the first parameter is the array containing the temperatures
  // the second parameter is number of elements of this array
  // to do: return the average of all temperatures in the array.

  double sum = 0.0;
  for (i = 0; i < numtemp; i++)
    sum = sum + hourlytemps[i];

  if (numtemp > 0)
    return sum / numtemp;
  else
    return 0.00;
}

again, use the information that is passed to the function

vijayan121 1,152 Posting Virtuoso

> he does say to pass the array to a function ...
i'm almost certain that he means 'pass the hourlytemps array to the function'. ignoring the array that is passed does not make sense. perhaps write it as the second example in post #15.

> I also have to average all 24 temps in a separate function, thats what I'm trying to figure out now
write another function to which you pass the array:

double average( const int hourlytemps[], int numtemp )
{
   double total = 0.0 ;
   // loop thru the array; in the loop add the array element to total
   return total / numtemp ;
}
vijayan121 1,152 Posting Virtuoso

void foo(int* a) and void foo(int a[]) are identical; they are not distinguishable from each other. they are the same void foo(int(&a) [N]) a is a reference to an array of exactly N elements. disadvantage: N must be a constant known at compile time. advantage: size of the array is known in the called function. there can be no programming errors wrt size.

> does any method have any performance gain as compared to other?
no.

vijayan121 1,152 Posting Virtuoso

well, you could simply write

void gettemps(  int numtemp )
{
  int count = 0;
  int temp ;
  while (count != numtemp)
  {
    cout << " Enter " << count << " :00 " << " temperature "<< endl;
    cin >> temp ;

    if (temp >= -51 && temp <= 131)
    {
      hourlytemps[count] = temp ;
      count ++; 
    }
  }
}

or better still, pass the array to be filled up (hourlytemps) as an argument

void gettemps(  int hourlytemps[ /* numtemp */ ], int numtemp )
{
  int count = 0;
  int temp ;
  while (count != numtemp)
  {
    cout << " Enter " << count << " :00 " << " temperature "<< endl;
    cin >> temp ;

    if (temp >= -51 && temp <= 131)
    {
      hourlytemps[count] = temp ;
      count ++; 
    }
  }
}
vijayan121 1,152 Posting Virtuoso

you could use librsync http://librsync.sourceforge.net/
to install (*BSD): as root, cd /usr/ports/net/librsync && make install clean or for binary package: as root, pkg_add -r librsync

vijayan121 1,152 Posting Virtuoso

this is one way to do it.

#include <iostream>
#include <sstream>
#include <iomanip>

int main()
{
  std::ostringstream stm ;
  stm << '$' << std::fixed << std::setprecision(2) << 123.4567 ;
  std::cout << std::setw(11) << std::setfill(' ') << std::right 
            << stm.str() << '\n' ;
}
vijayan121 1,152 Posting Virtuoso
// ..
{ 
   this->progressBar1->Value = (out / count) * 100;
   this->progressBar1->Invalidate() ;
   this->progressBar1->Update() ; // if immediate repaint is required
}
// ..
vijayan121 1,152 Posting Virtuoso
void gettemps(int temp[], int numtemp)
{
              int count = 0;

	while (count != numtemp)
	{
		cout << " Enter " << count << " :00 " << " temperature "<< endl;
		cin >> temp[count] ;

		if (temp[count] >= -51 && temp[count] <= 131)
			{
				hourlytemps[count] = temp[count];
				count ++; 
			}
	}
}

in void gettemps(int temp[], int numtemp) temp is a pointer. (presumably points to the first element of an array of size numtemp)
since the array hourlytemps is what you seem to be attempting to fill up, is there a need for a separate temp array?