gerard4143 371 Nearly a Posting Maven

Dude have you even tried my code? "hello," is gone and friend remains. Now, all i want is ",friend" gone and hello to remain.

Anyone else?

Actually nothing is gone. All you did was take a section of the string and create another string from it....dude.

#include <iostream>
    #include <string>
    using namespace std;
     
    int main()
    {
    char comma = ',';
    string str1 = "hello,friend";
    string str2 = str1.substr(str1.find(comma)+1, str1.length()); //i guess this line...
    cout << str2 << endl;
    cout << "original string->" << str1 << std::endl;
	//system("pause");
    return 0;
    }
gerard4143 371 Nearly a Posting Maven

Try googling C++ string erase.

gerard4143 371 Nearly a Posting Maven

Whats so bad about global vareable?

Here, more google nonsense.

http://stackoverflow.com/questions/484635/are-global-variables-bad

gerard4143 371 Nearly a Posting Maven

Just tried this and it works..

using System;

namespace testit
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			Console.WriteLine( inputMethod() );
		}
		
		public static float inputMethod()
        {
            float temp;

            if (float.TryParse("1234.45".ToString(), out temp))
            {
               return temp;
            }
            else 
            {
            	return 0.0f;
           	}
        }
	}
}
gerard4143 371 Nearly a Posting Maven

Try running this code

#include <stdio.h>

int main(void)
{
   float i=3.3;
   
   fprintf(stdout, "%f\n", i - 3.3);
   fprintf(stdout, "%f\n", 3.3 - i);
  return 0;
}
gerard4143 371 Nearly a Posting Maven

try

float.TryParse(txtInitialTemp.Text, out temp)
gerard4143 371 Nearly a Posting Maven

Declare the variables globally.i.e before main()

Yikes...Is that good advice?

Try reading up on references or pointers. I would try references first before plunging into pointers.

Simple reference example.

#include <iostream>

void square_it(int & i)//pass by reference
{
  i *= i;
}

int main()
{
  int i = 5;
  
  std::cout << i << std::endl;
  
  square_it(i);
  
  std::cout << i << std::endl;
  
  return 0;
}
gerard4143 371 Nearly a Posting Maven

people i still cant figure out the problem :O

We can't figure out what the problem is...Posting a chunk of code and stating that it doesn't work and then giving a brief but confusing explanation doesn't help us.

gerard4143 371 Nearly a Posting Maven

what all should i include to make it look decent?

A lot of work....

gerard4143 371 Nearly a Posting Maven

If you not comfortable with iterators then try

#include <iostream>
#include <string>
#include <iterator>

int main(int argc, char**argv)
{
  std::string str("This is the string to work with");
  
  std::cout << str << std::endl;
 
  str.erase(0, 8);
  
  std::cout << str << std::endl;
  return 0;
}
gerard4143 371 Nearly a Posting Maven

And how would this be done?

You read the above post?

gerard4143 371 Nearly a Posting Maven

Heres the thing, I don't want to remove part of the string with values (example +1, -7). Isn't there a way I can find the comma (,) within the string and remove it and whats before it?

Sure, just find what position the comma resides and then erase everything up to it.

gerard4143 371 Nearly a Posting Maven

Try googling C++ string or check this link

http://www.cplusplus.com/reference/string/string/erase/

Here's an example

#include <iostream>
#include <string>
#include <iterator>

int main(int argc, char**argv)
{
  std::string str("This is the string to work with");
  
  std::cout << str << std::endl;
  
  std::string::iterator begin = str.begin();
  std::string::iterator end = str.begin() + 8;
  
  str.erase(begin, end);
  
  std::cout << str << std::endl;
  return 0;
}
gerard4143 371 Nearly a Posting Maven

So it seems like I should use a DLL, but how do I use a DLL?

That's operating system specific...Which operating system are we talking about here?

gerard4143 371 Nearly a Posting Maven

I would try a static member function in myclass to construct the 'hidden' class.

gerard4143 371 Nearly a Posting Maven

Try initializing your array elements before you pass them to your function....Just like your error message indicated.

gerard4143 371 Nearly a Posting Maven

Didn't work sir. The output would be "Your bill is Php0.0".

Try assigning something to TP.

gerard4143 371 Nearly a Posting Maven

Try initializing TP to 0.0.

gerard4143 371 Nearly a Posting Maven

Is there any way to test if a string is an integer without having to convert the C++ string to a C_string?

std::string my_str = "123abc";


for (int i = 0; i < my_str.length(); ++i)
{
if (isdigit(my_str[i]))
{
//do something
}
}
gerard4143 371 Nearly a Posting Maven

If your trying to pass a function pointer, use typedef and it'll simplify your code.

typedef void (*myfunc)();

void thefunc(myfunc p)
{
//...
}
gerard4143 371 Nearly a Posting Maven

You'll have to investigate the stream character by character using isdigit().

gerard4143 371 Nearly a Posting Maven

Take a read here

http://www.newty.de/fpt/fpt.html#r_value

Especially the section - 2.7 How to Return a Function Pointer ?

gerard4143 371 Nearly a Posting Maven

Where's your constructor that accepts three integers?

gerard4143 371 Nearly a Posting Maven

It should be

fraction fraction::addFractions(fraction two)
{
//...
}
gerard4143 371 Nearly a Posting Maven

Try reading how to create function in C++

You have this.

float calcManagerGross(float)//??????float what?
{
     float rate, gross; 
     gross = 40*(rate); 
     return(gross);    
}

How could you write ~ 300 lines of code and not once check if the code was producing correct results?

gerard4143 371 Nearly a Posting Maven

If you want to isntall Code::Blocks for Windows go here

http://sourceforge.net/projects/codeblocks/files/Binaries/10.05/Windows/codeblocks-10.05mingw-setup.exe/download

It should start downloading Code::Blocks with the GNU gcc compiler...Note I would uninstall your previous Code::Blocks first.

gerard4143 371 Nearly a Posting Maven

Maybe you could isolate one function and that function call that produces the zeros and post that...Posting ~ three hundred lines of code and saying it doesn't work - fix it please - is infuriating.

gerard4143 371 Nearly a Posting Maven

Take a look at your braces in your if statement.

Try this

bool checkNumber(int arr[], int value)
{
	for(int i=0; (i < 10); i++)
	{
	  std::cout << arr[i] << std::endl;
		if(value == arr[i])
		{
			return true;	
		}
	}	
	return false;
}
phorce commented: Thank you +2
gerard4143 371 Nearly a Posting Maven

I would read the contents of this link

http://www.cplusplus.com/reference/string/string/

I would really pay attention when you get to the string's method find.

gerard4143 371 Nearly a Posting Maven

Well try including the header cctype and using the function

int isdigit(int c)
gerard4143 371 Nearly a Posting Maven

and how can i rearrange this using a for loop

Why would you use a for loop? The purpose of a for loop is to iterate over a collection of data a fixed number of times...If you want a for loop to behave like a while loop then try this.

for(;;)
{
break;//break on some condition
}
gerard4143 371 Nearly a Posting Maven

Hint.

Don't use gets its a dangerous function. Instead use fgets().
Don't use magic numbers like 100 use a macro like

#define ARR_SIZE 100

Also

int *k;

Should be

char *k;
gerard4143 371 Nearly a Posting Maven

If your an experienced programmer(Java/C++) then C# 4.0 in a Nutshell by Joseph Albahari, Ben Albahari is a good read.

gerard4143 371 Nearly a Posting Maven

What part of the program are you having problems with? I ask because a C program is mostly a C++ program.

gerard4143 371 Nearly a Posting Maven

Try passing the values as references.

gerard4143 371 Nearly a Posting Maven

Wow another on posting a homework assignment...Please read the forum rules about posting homework assignments.

gerard4143 371 Nearly a Posting Maven

What about them?[

How many processes will run ?
And which ones?

I told you, in the code you posted, only one thread is running.

gerard4143 371 Nearly a Posting Maven


And what about processes?

What about them?

gerard4143 371 Nearly a Posting Maven

Number one, The code doesn't run in a compiler. The code is compiled by the compiler so that it can run within an operating system environment.

How many threads? Just one, the main thread.

gerard4143 371 Nearly a Posting Maven

What's your copy constructor look like?

gerard4143 371 Nearly a Posting Maven

I would drop all the references to pointers(* &) and just use references like the above posting.

gerard4143 371 Nearly a Posting Maven

Why are you using a reference to a pointer in your equals operator?

ThuggyWuggy commented: Solved problem, thanks +1
gerard4143 371 Nearly a Posting Maven

Thought so, I was hoping I could force it to be a char...

You could cast it to character.

#include <stdio.h>

#define NINE (char)0x39

int main()
{
  fprintf(stdout, "%c %lu\n", NINE, sizeof(NINE));
  return 0;
}
gerard4143 371 Nearly a Posting Maven

Sorry its against the forum rules. You must first post your attempted code and any questions.

gerard4143 371 Nearly a Posting Maven

Really what the hell does messy and glitchy mean? If you want to show use what the proper output is supposed to look like then post a copy of it...messy and glitchy means nothing from our point of view.

gerard4143 371 Nearly a Posting Maven

Are posting your homework assignment?

gerard4143 371 Nearly a Posting Maven

Try creating a pipe. Here's a simple example.

#include <iostream>
#include <unistd.h>

enum PIPES {READ, WRITE};

int main(int argc, char**argv)
{
	int hpipe[2];
	pipe (hpipe);

	if (fork())
	{
		close (hpipe[WRITE]);
		
		int x = 0;

		while (true)
		{
			read (hpipe[READ], (char*)&x, sizeof(int));
			if (x < 0) break;	
			std::cout<<"child recieved->"<<x<<"\n";
		}

		close (hpipe[READ]);
	}
	else
	{
		close (hpipe[READ]);
		const int MINUS = -1;

		for (int i = 0; i < 1000; ++i)
			write (hpipe[WRITE], (char*)&i, sizeof(int));
		write (hpipe[WRITE], (char*)&MINUS, sizeof(int));
		close (hpipe[WRITE]);
	}
	return 0;
}
gerard4143 371 Nearly a Posting Maven

Try the escape sequence \" e.g.

std::cout << "this is a quote \"" << std::endl;
gerard4143 371 Nearly a Posting Maven

Your for statement is set up wrong.

for(int x=1, y=0; y < 5, x < 15; x++, y++)

Are you sure you want your condition part of a comma operator?

Try running this code.

#include <iostream>

int main()
{

  for (int i = 0, j = 0; i < 5, j < 15; ++i, ++j)
  {
	std::cout << "i->" << i << " j->" << j << std::endl;
  }
  return 0;
}
gerard4143 371 Nearly a Posting Maven

According to the link, its stored as an int.

http://cpp.comsci.us/etymology/literals.html