Narue 5,707 Bad Cop Team Colleague

IIRC, the event handlers will give you an EventArgs object that has this information.

Narue 5,707 Bad Cop Team Colleague

Well, to begin with, you're reading a leading character from the file. If that leading character is actually part of one of the numbers you want to read, you've corrupted your input stream by changing the starting offsets of each read. Further, the variable you're using to read numbers is a char, so you're not really reading numbers. Instead of this:

inStream.get(temp);
while (!inStream.eof()) {
  L1.insert(temp);
  inStream >> temp;
}

Try this:

int temp;

while ( inStream>> temp )
  L1.insert ( temp );
Narue 5,707 Bad Cop Team Colleague

What have you tried so far? This is actually a simple enough project because you can easily figure out the steps on paper and then translate those steps directly to C++. So your first order of business should be to work out the exact steps of adding a binary number on paper.

Narue 5,707 Bad Cop Team Colleague

Like this?

#include <iostream>

class Foo {
public:
  bool call ( int i )
  {
    switch ( i ) {
    case 0: a(); break;
    case 1: b(); break;
    case 2: c(); break;
    default:
      return false;
    }

    return true;
  }
private:
  void a() { std::cout<<"Calling a\n"; }
  void b() { std::cout<<"Calling b\n"; }
  void c() { std::cout<<"Calling c\n"; }
};

int main()
{
  Foo f;

  for ( int i = -1; i < 4; i++ ) {
    if ( !f.call ( i ) )
      std::cerr<<"Invalid selection\n";
  }
}
Narue 5,707 Bad Cop Team Colleague

I'm not sure I understand what you want. I'll guess, probably be wrong, and then ask you to describe the problem in a different way. So here's my guess:

#include <iostream>
#include <stdexcept>

class Foo {
  int _a;
  int _b;
  int _c;
public:
  Foo ( int a, int b, int c )
    : _a ( a ), _b ( b ), _c ( c )
  {}

  int get_value ( int i )
  {
    switch ( i ) {
    case 0: return _a;
    case 1: return _b;
    case 2: return _c;
    default:
      throw std::runtime_error ( "Invalid selection" );
    }
  }
};

int main()
{
  Foo f ( 10, 20, 30 );

  for ( int i = -1; i < 4; i++ ) {
    try {
      std::cout<< f.get_value ( i ) <<'\n';
    } catch ( std::runtime_error& ex ) {
      std::cerr<< ex.what() <<'\n';
    }
  }
}
Narue 5,707 Bad Cop Team Colleague

>you are just rude about it
Yes I am. If you don't like it, put me on your ignore list.

>how about this AD
That's much better. However, you're still doing exactly the same thing in both branches of the if..else. Perhaps something more like this:

if ( num % 2 == 0 )
  cout<< num <<" is even\n";
else
  cout<< num <<" is odd\n";

Also, you can compact this:

ifstream AFile;      
AFile.open("a:\\OddFile.txt");

Into this:

ifstream AFile("a:\\OddFile.txt");

Because ifstream has a constructor that does the same thing as open.

Narue 5,707 Bad Cop Team Colleague

>Are you trying to help
Yes.

>or do you go to everybodys thread and insult them
Only if they deserve it.

>and assume they are not trying
I see a distinct lack of effort on your part.

>yea thats why I rather have a human being better explain the error messages
You haven't posted any error messages. Thus, nobody can explain them to you. You wanted us to tell you exactly what was wrong with your code and how to fix it, it seems.

Narue 5,707 Bad Cop Team Colleague

>I know but I don't see what the problem with it is
Did you try reading the error? Did you try comparing your other code that does the same thing (opens a file)? Did you try anything? I'm quickly starting to think that you're posting farce threads like this just to screw with us.

Narue 5,707 Bad Cop Team Colleague

Yes, that's one of the problems with your program. Good job!

Narue 5,707 Bad Cop Team Colleague

>Do you see anything wrong with this
Yes, I do. Clearly you haven't compiled or run this code, otherwise you would see something wrong as well. I suggest you do that.

Narue 5,707 Bad Cop Team Colleague

Reverse your order of opening. Open the main form (but don't show it). Then from the main form's load event open the login form. If the login is valid, show the main form and close the login form. If the login is invalid, do an Application.Exit() or close the main form.

What's happening right now is that the login form is your main form as far as .NET is concerned because it's the first form opened. When the main form closes, the application terminates.

Narue 5,707 Bad Cop Team Colleague

>Nurue
Narue.

>I dont think I understand what do you mean about the
>center line and making it a special case outside the for loop
Hmm, I can see why when I posted the wrong code... This is what I meant to post:

#include <iostream>
#include <iomanip>

using namespace std;

void main()
{
  int space = 2;
  int counter = 19;
  int count = 1;

  cout << "Assignment 1 --- Question 2.2" << endl;
  cout << endl;
  cout << setfill('*') << setw(23) << "*"  << endl;
  cout << setfill('*') << setw(23) << "*"  << endl;

  for(int x = 1; x < 10; x++)
  {
    counter--;
    cout << "**";
    cout << setfill(' ') << setw(count);
    cout << setw(count) << "*" << setfill(' ');
    cout << setw(counter) << setfill(' ') << "*";
    cout << setw(space) << setfill('*') << setfill(' ') << "**" << endl;
    count++;
    space++;
    counter--;
  }

  cout << "**";
  cout << setfill(' ') << setw(count);
  cout << setw(count) << "*" << setfill(' ');
  cout << setw(space) << setfill('*') << setfill(' ') << "**" << endl;

  for(int x = 1; x < 10; x++)
  {
    space--;
    count--;
    counter++;
    cout << "**";
    cout << setfill(' ') << setw(count);
    cout << setw(count) << "*" << setfill(' ');
    cout << setw(counter) << setfill(' ') << "*";
    cout << setw(space) << setfill('*') << setfill(' ') << "**" << endl;
    counter++;
  }

  cout << setfill('*') << setw(23) << "*"  << endl;
  cout << setfill('*') << setw(23) << "*"  << endl;
  cout …
Narue 5,707 Bad Cop Team Colleague

Simple solution: Make the center line a special case outside of the loops and change the condition of the loops to be < 10 rather than <= 10:

#include <iostream>
#include <iomanip>
using namespace std;

void main()
{
  int space = 2;
  int counter = 19;
  int count = 1;

  cout << "Assignment 1 --- Question 2.2" << endl;
  cout << endl;
  cout << setfill('*') << setw(23) << "*"  << endl;
  cout << setfill('*') << setw(23) << "*"  << endl;

  for(int x = 1; x < 10; x++)
  {
    counter--;
    cout << "**";
    cout  << setfill(' ') << setw(count);
    cout << setw(count) << "*" << setfill(' ');
    cout << setw(counter) << setfill(' ') << "*";
    cout << setw(space) << setfill('*') << setfill(' ') << "**" << endl;
    count++;
    space++;
    counter--;
  }

  for(int x = 1; x < 10; x++)
  {
    space--;
    count--;
    counter++;
    cout << "**";
    cout  << setfill(' ') << setw(count);
    cout << setw(count) << "*" << setfill(' ');
    cout << setw(counter) << setfill(' ') << "*";
    cout << setw(space) << setfill('*') << setfill(' ') << "**" << endl;
    counter++;
  }
  cout << setfill('*') << setw(23) << "*"  << endl;
  cout << setfill('*') << setw(23) << "*"  << endl;
  cout << endl;
}

>All you have to do is replact <= 10 to < 10 in each of the two loops
That doesn't quite solve the problem.

Narue 5,707 Bad Cop Team Colleague

>I am contemplating moving from c# to VB
Ideally you should learn them both. The actual languages aren't overly complicated, it's the .NET framework that has a huge learning curve. So if you already know the framework, you should have the more common .NET languages in your repertoire.

>if I am quite knowledgable in c#, will vb be easy to pick up?
Yes, but if you're used to C#, you'll find yourself cursing the syntax. ;)

>what is the difference between, say VB.net and vb6 ?
In my opinion, the only similarity is Basic-like syntax.

Narue 5,707 Bad Cop Team Colleague

>Since i was doing a (length-1) in the loop that was not the problem
Yes, that was the problem. You allocated length characters to px. Let's say for the sake of brevity that length is 5. That means the first index is 0 and the last index is 4. px[4] is where your null character should be placed, and px[5] is out of bounds. This is your loop, which stops at length-1:

i = 0, px[0] = *ps
i = 1, px[1] = *ps
i = 2, px[2] = *ps
i = 3, px[3] = *ps
i = 4, break
// The loop is done at this point, i == 4
// This is where your bug is, you increment i again
i = 5
px[5] = '\0'

Notice that you never assigned anything to px[4]. This is the gap in your off-by-one error, and that's where your garbage character is coming from. Using memset doesn't solve the problem, it simply hides it by pre-setting px[4] to '\0'. You still have an off-by-one error, and you're still writing to px[length], which is out of bounds.

Narue 5,707 Bad Cop Team Colleague

>i++;
>px = '\0';
That last increment of i is one too many. I'd wager that explains your mystery character.

Narue 5,707 Bad Cop Team Colleague

Can you define "junk" for us?

Narue 5,707 Bad Cop Team Colleague

>You cannot print the whole array in one action.
Sure you can:

#include <algorithm>
#include <cstddef>
#include <iostream>
#include <iterator>

template <typename T, std::size_t N>
T *end ( T (&array)[N] ) { return array + N; }

int main()
{
  int a[] = {1,2,3,4,5,6,7,8,9,0};

  copy ( a, end ( a ), std::ostream_iterator<int> ( std::cout, "\n" ) );
}

>You cannot input a whole array in one action.
Sure you can:

#include <algorithm>
#include <cstddef>
#include <iostream>
#include <iterator>

int main()
{
  int a[10];
  int *end;

  // Unsafe
  end = copy (
    std::istream_iterator<int> ( std::cin ),
    std::istream_iterator<int>(),
    a );
  copy ( a, end, std::ostream_iterator<int> ( std::cout, "\n" ) );
}

That's not a particularly good idea though, as it's effectively an unbounded loop, so you've got the risk of buffer overflow on your array:

#include <algorithm>
#include <cstddef>
#include <iostream>
#include <iterator>

int main()
{
  int a[10];
  int *end;

  end = a;

  // Unsafe
  while ( std::cin>> *end )
    ++end;

  copy ( a, end, std::ostream_iterator<int> ( std::cout, "\n" ) );
}

However, you can write your own copy_n algorithm and using it still counts as one action:

#include <algorithm>
#include <cstddef>
#include <iostream>
#include <iterator>

namespace jsw {
  template <typename In, typename Out, typename Count>
  Out copy_n ( In first, In last, Count n, Out dst )
  {
    while ( n-- > 0 && first != last )
      *dst++ = *first++;

    return dst;
  }
}

int main()
{
  int a[10];
  int *end;

  end = jsw::copy_n …
Narue 5,707 Bad Cop Team Colleague

>I posted the Fortran code
Really, I hadn't noticed. :icon_rolleyes: It's lunchtime where I am, so I was finishing my sandwich before I replied. Please don't bump your threads if you don't think your question is answered fast enough.

This compiles, but I didn't run it.

#include <cmath>
#include <iostream>

double F ( double X )
{
  // X**4-9*X**3 - 2*X**2 + 120*X -130
  return std::pow ( X, 4.0 ) - 9
    * std::pow ( X, 3.0 ) - 2
    * std::pow ( X, 2.0 ) + 120 * X - 130;
}

int main()
{
  double X, XL, XR, XS, Y, YL, YR;
  double XB, XND, STEPSIZE;

  XL = 0.0;
  XR = 0.0;
  XS = 0.0;

  X = 0.0;
  Y = 0.0;
  YL = 0.0;
  YR = 0.0;

  XB = 0.0;
  XND = 0.0;
  STEPSIZE = 0.0;

  std::cout<<"What is the left-most interval endpoint? ";
  std::cin>> XB;

  std::cout<<"What is the right-most interval endpoint? ";
  std::cin>> XND;

  std::cout<<"What is the desired step-size for function evaluation? ";
  std::cin>> STEPSIZE;

  XL = XB;

  while ( true ) {
    YL = F ( XL );
    XR = XL + STEPSIZE;
    YR = F ( XR );

    if ( YL * YR > 0 ) {
      if ( XR >= XND ) goto end;

      XL = XR;
      YL = YR;
    }

    if ( YL * YR == 0 ) {
      if ( YL == 0.0 ) {
        std::cout<<"This is a root."<< XL;

        if ( XR >= XND ) goto end;

        XL = …
Narue 5,707 Bad Cop Team Colleague

1) It's generally used for declaring and dereferencing pointers.

2) a_base works with base2dec and b_base works with dec2base. You can name them whatever you want as long as they're valid identifiers.

3) The longest number would be in base 2 (binary), so it makes sense to set the size of the output array to the number of bits used to represent your value.

4) In value2digit, he's looking up the character representation of the digit he wants to convert. For example, if the hexadecimal value of the digit is 12, looking up digits[12] give you 'c'. In digit2value, he's doing the opposite: searching for the digit character and using the index as the digit value. For example looking up 'c' in digits stops at index 12, which is the correct value.

5) Add the language you want the code to be highlighted for:

[code=cplusplus]
<your code here>
[/code]

Narue 5,707 Bad Cop Team Colleague

Yea...post the Fortran code so that I have a point of reference for what you were trying to do.

Narue 5,707 Bad Cop Team Colleague

>"Using namespace std;" was not written
Because it would have been an error. Notice that <iostream.h> (the pre-standard form, before namespaces) was used instead of the standard <iostream>.

>However the "(float)" Cast also isnt nesesary
Yes, it is. Both SolValue and NumOfSold are integers. If the result of division is less than 0, the precision will be lopped off and the result would be 0. Even if the result is greater than 0, all precision will be lost. The solution is to convert at least one of the operands to floating-point so that it becomes floating-point division rather than integer division.

Narue 5,707 Bad Cop Team Colleague

>I'm concerned that the number I arrive at will scare
>off my client from future development opportunities
I worried about that at first, but custom software is expensive, and quality custom software is more expensive still. You need to stick to your guns on the base price[1], or they'll end up taking advantage of you. Here are two reasonable arguments for defending your price that any reasonable client will respect:

Clients should be aware that if they want someone to write an application just for them, according to their specific needs, they're going to pay more than if they bought a "close enough" package at retail prices. This is the balance of value for cost; custom software is vastly more valuable because it does exactly what the client needs.

Another factor is the the number of clients you can reasonably sell this application to. If you can't productize it for some reason, or have no plans to sell the same or a similar solution to other clients, you can't compete with software houses that have hundreds or thousands of buyers. To make a profit, your price goes up if the project is to be worth your time. Clients should be aware of this as well.

If your price is fair, your concerns are unfounded.

[1] For repeat clients with which you have a good relationship, discounts and generous support contracts are an excellent way to keep their business.

jephthah commented: interesting +1
Narue 5,707 Bad Cop Team Colleague

>receive the sold value for each item
The "for each" part suggests that you need a loop unless you can guarantee that the sold value is identical for all items:

start
get <sold items>
for number = 1 to <sold items>
  get <sold value>
  sum = sum + <sold value>
  Display number, ": ", <sold value>
loop
average = sum / <sold items>
Display average
Narue 5,707 Bad Cop Team Colleague

>could you give me some examples of how you
>determine cost for the products that you develop?
For software I develop as a consultant, I typically multiply the estimated hours by my hourly rate ($200USD) for the full price. Half of the price is due on signing of the statement of work, and the rest is due on delivery. The estimated hours is basically how long I think it will take, plus 50% to account for unexpected delays, implementation problems, unexpected redesign, and allowable feature creep.

Narue 5,707 Bad Cop Team Colleague

>I am wondering why size_t is used when it has the same functionality as an int
Because it doesn't have the same functionality as int in all cases. size_t is an unsigned type and int is a signed type. That alone will cause warnings and sometimes odd behavior. size_t is also not required to match the size of int.

>assigning size_t type variable to int works fine.
Only if the value in the size_t variable can be represented by int. Otherwise you've invoked undefined behavior. The only way this assignment could be safe is if size_t is smaller than int, which isn't a common case.

Narue 5,707 Bad Cop Team Colleague

You're missing a comma between the address and handphone arguments in your call.

Narue 5,707 Bad Cop Team Colleague

As darkagn has already said, we're not a homework service. We're a resource for education. Much like your teacher isn't going to do your homework for you, the same goes for us because that defeats the purpose of this forum.

However, I will link you to a sorting tutorial with plenty of code examples and thorough descriptions. There aren't any flowcharts, so you'll actually have to understand how they work to a certain extent by working through the code.

Narue 5,707 Bad Cop Team Colleague

I forgot to add a step. It's fixed now.

Narue 5,707 Bad Cop Team Colleague

>but with out chaging the order of the array...
*sigh* You know, that's an important piece of information. Here's something to shut you up for a bit. It's a simple solution to your problem that you can use as a template for your own code:

#include <stdio.h>

int min_index ( int a[], int skip[], size_t n )
{
  int min = 0;
  size_t i;

  while ( min < n && skip[min] == 1 )
    ++min;

  for ( i = 1; i < n; i++ ) {
    if ( skip[i] != 1 && a[i] < a[min] )
      min = i;
  }

  return min;
}

int main ( void )
{
  int a[] = { 10, 5, 20, 3, 50, 40 };
  int skip[6] = {0};
  int i;

  for ( i = 0; i < 6; i++ ) {
    int min = min_index ( a, skip, 6 );

    printf ( "%d\n", a[min] );
    skip[min] = 1;
  }

  return 0;
}
Narue 5,707 Bad Cop Team Colleague

>with out using any type of sort
Be more specific, please. You can't use an existing sort function? Any sorting algorithm at all?

Narue 5,707 Bad Cop Team Colleague

>I thought we could address the problem without having the circularity.
The best way is to not introduce circularity. Personally, I think you should be designing your Point class to be completely independent, then the Line class to use the Point class. In other words, I see no reason why a Point should know or care how to make a Line. That's the job of the Line class.

Narue 5,707 Bad Cop Team Colleague

>The Point class needs to have member functions that return type Line
That sounds like a design flaw, actually.

>if I have a situation like this, then in class Line I can only have members of type *Point
That's only a problem if both classes are mutually dependent. In other words, the Line class has a Point data member and the Point class has a Line data member. This kind of circular relationship causes infinite recursion. However, in your case the Point class doesn't contain a Line object, so you don't have to store pointers to Point objects in the Line class, if that makes sense.

Narue 5,707 Bad Cop Team Colleague

Wow, I was just explaining interfaces to a coworker the other day. Freaky.

>Does any one know a robust benefit of using interfaces?
Consider the concept of data hiding. Let's say you want to provide a class to some client code, but don't want to give them full access. One way to restrict access without limiting the functionality of your class is to implement an interface and require the client code to get objects through a factory:

using System;

namespace JSW {
	public class Program {
		static void Main() {
			IFoo myfoo = FooFactory.GetFoo();
			Bar mybar = new Bar();

			myfoo.Print();
			mybar.Print();
			mybar.Test();
		}
	}

	// Restricted type for clients
	public interface IFoo {
		void Print();
	}

	// Factory for clients
	public class FooFactory {
		public static IFoo GetFoo() {
			return new Bar();
		}
	}

	// Fully functional type for us
	internal class Bar: IFoo {
		public void Print() {
			Console.WriteLine( "Foo!" );
		}

		public void Test() {
			Console.WriteLine( "Test" );
		}
	}
}

This is especially useful when interfacing with COM.

Another benefit of interfaces is team development. If you have a dozen programmers working on different pieces of code that need to connect, it's best to define interfaces for the connections. As long as the programmers write according to the interfaces, everything will link together nicely regardless of personal choices and style.

Yet another benefit is that with interfaces you can use a class without having defined it first. For example, if you have …

Narue 5,707 Bad Cop Team Colleague

>I'm using Ms Visual Studio 6
Use something newer. Visual Studio 6 was released before C++ was standardized, so you'll have a lot of problems trying to learn correct C++. Visual C++ 2008 Express is a free download, so there's really no excuse to continue using a relatively ancient compiler.

>is it better using your own made constructor/destructor or leave it be to the default one
It depends on the data members of your class. But it's never wrong to explicitly define the default constructor.

Narue 5,707 Bad Cop Team Colleague

>I just want to validate that the entered text in the text box is of correct format(date type).
Try to parse it.

Narue 5,707 Bad Cop Team Colleague

First, your code shouldn't compile because fibArr tries to use implicit int for the return value, which is illegal C++. Second, you don't even try to print the result of fibNum. Third, you should release the memory you allocate in fibArr. Finally, and this is the biggest error, you're not properly setting num, which is causing fibArr to seg fault. You're not even really using that data member, so you might as well just get rid of it:

#include <iostream>
using namespace std;

class fibonacci
{
public:
	long fibNum( int n );
	void fibArr( int n );
};
//============================
long fibonacci::fibNum(int n)
{
	if (n<0) { return 0; }
	if (n<2) { return n; }
	else { return fibNum(n-1) + fibNum(n-2); }
}
//============================
void fibonacci::fibArr(int n)
{
	int *Arr;
	Arr=new int[n];

	for (int i=0; i<n; i++)
	{ 
		Arr[i]=fibNum(i);
		cout<< Arr[i] << " ";
	}
}
//============================
int main()
{
	fibonacci fibo;

	cout<< fibo.fibNum ( 10 ) <<'\n';
	fibo.fibArr ( 10 );

	return 0;
}
Narue 5,707 Bad Cop Team Colleague

The Date type has a Parse method that will try to convert a string to a date:

dim s_date1 as string
dim s_date as date
s_date1 = s_mon & "/" & s_day & "/" & s_year
s_date = Date.Parse ( s_date1 )
Narue 5,707 Bad Cop Team Colleague

>Does anything goes slower or can something crash ?
It's a ripe field for bugs, and debugging preprocessor errors is surprisingly difficult.

Narue 5,707 Bad Cop Team Colleague

>you should take a look at: stringize and the token-pasting operators
As a general guideline, you should avoid the more advanced features of the preprocessor unless you have good reason not to.

>Is it correct that the std::string Word contains: "Number == 5"
Yes, your code is functionally identical to this:

std::string Word;
Word = "Number == 5";
Narue 5,707 Bad Cop Team Colleague

>My question is if it is possible to put this: Number == 5
>to a std::string in any way through Replace ?
Do you mean you want to use Replace and get "Number == 5"? The short answer is no. If you want that, you need a separate define that does it for you:

#define ReplaceS "Number == 5"

If that's not what you mean, please elaborate.

Narue 5,707 Bad Cop Team Colleague

>I would like to know what people recommend in terms of programming language
>or software to develop a front end interface which will interface with a database
>which could be Access or an sql.
I don't see why Visual Basic isn't a good enough solution for you (both front end and back end), especially if you already know it.

Narue 5,707 Bad Cop Team Colleague

>Does it have something to do with the braces being gone off of the else?
You got it in one. If you omit the braces, only the next statement will be a part of the block. If you add braces in the way that your compiler parses the code, it looks like this:

cout<<"Enter in total widgets: ";
cin>>totWidgets;

if (totWidgets > 250)
{
    discAmt1 = 25;
    discAmt2 = 5;
}
else if (totWidgets > 150)
{
    discAmt1 = 15;
    discAmt2 = 2.50
}
else
{
    discAmt1 = 5;
}

discAmt2 = .5;

cout<<"Discount amount 1 is $ "<<discAmt1<<endl;
cout<<"Discount amount 2 is $ "<<discAmt2<<endl;

As you can see, because totWidgets is greater than 150, but not greater than 250, discAmt1 is set to 15 and discAmt2 is set to 2.50. However, after the if..else construct, discAmt2 is always set to .5 because it's not part of the if..else construct.

Narue 5,707 Bad Cop Team Colleague

>I want to create a web based rpg that will includ emany different
>charecters such as Master Cheif and Mario and many others.
Good luck with the licensing headaches.

>I am looking fo some help/ideas/comments.
Help: Spend a few years working on less ambitious games.
Ideas: Don't rip copyrighted characters.
Comments: You're in way over your head.

Narue 5,707 Bad Cop Team Colleague

>I know there must be a way to do it...
There's not a way to do it. Structures have a set size at compile-time. However, I get the impression that you simply don't know how to express your problem and ended up asking for something impossible. It looks like you want to have a dynamic array using pointers and memory allocation:

#include <iostream>

using namespace std;

struct SScore {
    char m_szFirstName[15];
    char m_szLastName[15];
    int m_Score;
};

int main()
{
    SScore *golfers;
    int total;

    cout<<"Enter number of golfers: ";
    cin>> total;

    golfers = new (nothrow) SScore[total];

    //...
}

However, you'd be much better off using the std::vector class, because it saves you the hassle of managing the memory.

Narue 5,707 Bad Cop Team Colleague

You're opening and closing the files with each iteration of the loop. When you close the file and open it again, you start reading back at the beginning.

Narue 5,707 Bad Cop Team Colleague

>how it is possible to remove "dublicates" from Values(6) ?
I'd start by sorting the vector and calling std::unique on it. Of course, that's mentally translating "dublicate" into "duplicate". If you really do mean "dublicate", I have no idea what you're talking about.

Narue 5,707 Bad Cop Team Colleague

Programmers are always confused. It's a fact of life. So start at the top and go one error at a time. Often one error will cause others, and the cascade effect overwhelms you. So don't treat it as 44 errors and 1 warning that you don't understand, treat it as

dynarray.h(28) : error C2061: syntax error : identifier 'itemType'

Ask yourself, "what is itemType?", and "why wouldn't my compiler recognize it?".

mitrmkar commented: A good piece of advise, should (somehow) be made clear to all the beginners +1
Narue 5,707 Bad Cop Team Colleague

>how can one find the upper limit of an array?
Assuming the upper limit in terms of capacity, you can use the Length property. my_array.Length gives you the number of items the array can hold, and my_array.Length - 1 gives you the last valid index.

>ow can one change that upper limit?
Rebind the reference to a new array:

using System;

namespace JSW {
  class Program {
    static void Main() {
      int[] my_array = new int[5];

      Console.WriteLine( "Size: {0} -- Last: {1}",
        my_array.Length, my_array.Length - 1 );

      my_array = new int[10];

      Console.WriteLine( "Size: {0} -- Last: {1}",
        my_array.Length, my_array.Length - 1 );
    }
  }
}

The size of an array is locked down when you create the object. If you want an array that can be resized, you use a List<T> object (or an ArrayList prior to .NET 2.0), or some other suitable collection.

majestic0110 commented: Thank you, good explanation +1
Narue 5,707 Bad Cop Team Colleague

>Here's one possible way to get desired string2:
It's generally considered rude to provide a complete solution when the OP hasn't shown any proof of effort.

>#include<iostream.h>
This header is no longer valid C++. Many newer compilers will refuse to compile it, and some of them have done so for several versions. You'd best get a modern compiler and keep your code standard wherever possible.

>cout<<"enter string 1 length : ";
I don't particularly mind that you're using C-style strings, but it's not the best practice to give your users this kind of control. A user shouldn't have to care about the length of a string; it's your responsibility to deal with what they give you.

>cin>>p;
Well, so much for the safety of asking for a length. What's to stop me from telling you the length is 5 and then typing 5,000 characters?

>int l=strlen(q);
l is a very, very poor variable name because depending on the font, it could be confused with the digit 1. However, kudos for not calling strlen in the condition of your loop.

>for(int i=0;i<l;i++);
This loop does nothing. Note the semicolon.

>*(q+i)=*(q+(i-4));
There's no reason to use pointer notation. It doesn't make you look any smarter and only serves to complicate your code.

Finally, your code doesn't even come close to solving the problem as given by the OP, though you seem to have the right idea. Perhaps you …