Here's a thought. Keep dividing the number by 10 until it goes to zero.
7631/10 = 763
763/10 = 76
76/10 = 7
7/10 = 0
Type: Posts; User: rocketman50
Here's a thought. Keep dividing the number by 10 until it goes to zero.
7631/10 = 763
763/10 = 76
76/10 = 7
7/10 = 0
Ah I see, you want spaces from the left.
You are very almost there. An easy way to modify your code is to do the following.
First, sort out the brackets
for(int i=0; i<5; i++){...
You should give all the for loops curly brackets, even if you don't need to. It makes the code easier to read and helps reduce mistakes.
Also, I think you should be able to do it with only 2 for...
Hey,
I have a file containing the number 1. I want to make a program that reads the number in the file, and then replaces the number incremented by 1.
so far I have this, but it does not seem...
Hello,
I am trying to create my first windows form using visual C++. To create the form I use the following code in my .cpp file
Form1^ fas;
fas = gcnew Form1();
...
Thanks very much, this code now works. Also, congratulations on hitting 10k posts!
Form1^ fas;
fas = gcnew Form1();
fas->addText();
Application::Run(fas);
Thanks, I had tried that before but I got slightly confused by the error message it gives
1>.\form.cpp(18) : error C2665: 'System::Windows::Forms::Application::Run' : none of the 3 overloads...
Hello,
I'm using visual C++ to try and create a window which will display various bits and bobs from my program. For example, I have a text box which I want to fill with a list of strings...
I've pieced together your code (didn't bother using a header file) and it seems to work fine for me?
#include<iostream>
#include <fstream>
#include <string>
using namespace std;
class...
The left hand side of '=' should refer to the variable in which you would like the resulting expression (on the right hand side) to be stored. At the moment you are saying store number3 in number1 +...
Not sure if this is what you are after, but if you change
#include <cstring>
to the C++ version
#include <string>
Are you sure you have to use three separate arrays? It would be better to define your own data structure I think. Anyway, just declare the arrays like this: - remember to include the "string" library...
Hey guys,
I have a piece of code here that gives the wrong answer
int a = 5;
float result;
float b = 10;
Hey, I'm not sure if this is the right place to post this but anyway.
Does anyone know of an algorithm which can be used to print out decimal values from a register using machine code.
...
Thanks Mats
I can confirm that this now works
cout << ptr->objectPtr->GetVarID() << endl;
Hello
I am trying to create a linked list of the following style:
#include "variable.h" // CLASS called variable
struct node{
variable *objectPtr;
Ah thanks, I never heard of strcmp() before. Usually just deal with numbers!
code is now working fine, thanks for the fast help!
I do in fact want just a single string, thanks.
The code now looks like this:
int Getnumber(char *name){
search = head; //set searchptr to head of the list
while (search->next...
Hello
I have a program that is working how I want it, but I am distressed by a compiler warning. I therefore assume I have poor code and would like to know if this is the case.
Basically what...
great, I really appreciate the help. I have an exam tomorrow. I should really be asleep right about now...i really need to get my head around recursion first!
cool, thanks for the help.
Just to clarify - im being slow (its 4am ><)
The base case is tree == NULL.
So the function will start by traversing down the left most branch until it reaches the...
you know, i think you're right. I think it did help. But when the does the tree == NULL?
is there a 'NULL' node at the end of each branch?
Just a quick note, i think i understand the last bit
if (leftdepth > rightdepth)
return leftdepth +1;
else
return rightdepth + 1;
Basically, if the the tree is greater on the...
Hey guys, i was wondering if anyone could explain this to me
int maxdepth (treeptr tree){
int leftdepth = 0;
int rightdepth = 0;
if (tree == NULL)
return 0;
else{
Hey guys. I have a problem with writing to a file.
I will try and simplify the problem so it might sound strange.
Lets say I have a function which works out a series of numbers, once each...