dkalita 110

you can use
[CODE]scanf("%[^\n]",...);[/CODE] as well to scan a whole line.

Ancient Dragon commented: good point +36

dkalita 110

there is nothing in the outbuffer variable.
You are modifying the variable "outs" everytime. So reset it after every itereations to "".

When you wrote
[CODE]ostringstream outs(outbuffer);[/CODE]
the outs variable is initialised with the string in the variable "outbuffer", it does not correlate to that variable.
So reset "outs". And at the end print outs.str() instead of "outbuffer".

dkalita 110

[CODE]

include

using namespace std;
int main()
{
int matrix;
int dimension;
/
read dimension first and initialise "dimension" and then allocate apropriate memory to "matrix" and then read the matrix into this array. This can also be done inside a function which will make your code more usable*/

/process the matrix, better write a function and pass the matrix to it and do the processing inside that./

/write back the new matrix data into the same file. This can also be put inside a function./
}
[/CODE]

This is how you can start.
Write the fileRead, matrixProcess, and fileWrite method seperately and test them thoroughly before writing the next function.

dkalita 110

[QUOTE=lotrsimp12345;1070833]but my teacher wants a constructor and a destructor. So i guess i have to use pointers.[/QUOTE]
upto u.
U can keep your constructor/destructor where u might want to do something else, or yes, u can use pointers.

dkalita 110

include [B]stdbool.h[/B]

The type is "bool"

e.g.
[CODE]

include

bool b= true;
[/CODE]

this works in my compiler(cc).

Iam3R commented: Thanks +1

dkalita 110

[code]
int main()
{
int two_d[10][20];
return 0;
}
[/code]
take it....

or else tell us what problem u are facing with 2d array.....

dkalita 110

[B]tower of hanoi [/B]is a very good example for solving by recusrion.

Though recusrion is helpful at times while solving some very critical problems though it has some demerits. Read about recursion in more detail to know its merit and demerits.

dkalita 110

u r welcome

dkalita 110

hey thats the Counter class. Sorry I misspelled it.
Make it as
[CODE]
int Counter::count = 0;
[/CODE]

Nick Evan commented: Simple fix, problem solved! +10

dkalita 110

u must intialize a static member.
Add the line
[CODE]
int Counter::count = 0;
[/CODE]
before main() or other module where u are using or just after declaring your class.

A static data member must always be initialized before being used.

dkalita 110

the function fun() takes a funtion(whose return type is int and with no params) pointer as its argument.
And u are sending [B]main[/B] to that funcion.
Thats it.
Read on pointer to function.

dkalita 110

May be u can get some hint from this thread.
[url]http://www.daniweb.com/forums/thread33551.html[/url]

Many of the machine info u can get from the files present in the following folder:

[B]/proc/sys/kernel[/B]

dkalita 110

[CODE]
void f(int a) //its a pointer to a pointer. The argument to the function f is a pointer to pointer
{
cout <<
a; //prints the value stored in a, output is 45
cout << *a; //address of the memory where 45 is stored
cout << &a; //address of variable 'a' (it will come as ***)
}

//I'm OK with main(). I'm including it FYI
int main()
{
int i = 45;
int ptr = &i;
f(&i);/
u r passing incorrect arg/
/
passing 'int *' instead of 'int *'/
/should have called as: f(&ptr);/
}

[/CODE]

EDIT: correction
line #5: its "int " and not simply "" in the comment.

necrolin commented: Thank you +1

dkalita 110

remove the -ansi option while compilation. Just do
gcc -Wall client.c

BestJewSinceJC commented: Thanks! Wish I could give you more rep. +4

dkalita 110

Just explore this site a bit.
Infix to postfix conversion has been discussed earlier in many threads.

dkalita 110

u haven't initialized the variables
[B]myLineNumbers and temp[/B]

and u are trying to operate on it.

Initialize them in the constructor as:
[CODE]
myLineNumbers = new Queue();
temp = new Queue();
[/CODE]

dkalita 110

[QUOTE=noey699;1028141]i am not sure but it might be
friend ostream& operator<< (ostream &, const GrabStuff&);
needs a space between operator and <<
so it would be
friend ostream& operator << (ostream &, const GrabStuff&);[/QUOTE]

That is not an issue. I dont know why that error is coming though but I have tested it without space and works fine.

[B]Error 2>[/B]
[CODE]
ostream& operator<< (ostream &os, const GrabStuff &name)
{
os << name.myWord << " ";
while (!myLineNumbers.isEmpty()) /*IN THIS LINE***/
{
// blahblah
}
return os;
}
[/CODE]
Should have done
[CODE]
while (!name.myLineNumbers.isEmpty())
[/CODE]

crystality commented: fixed my problem +0

dkalita 110

[QUOTE=seoudi;1024119]Create a program that displays a pyramid , square and a triangle using the multiply character “*” as follows:
welcome to c++
shape for pyrasmid
sqyare
trinagle[/QUOTE]
In C++ u have so many features available such as: [B]cout[/B], [B]for loop[/B], etc.
Use them along with your [B]brain[/B]. That will help get the solution.

If while coding u need some help, then go ahead, post your issues here. We are here to help u.

Show some effort then only we help.

dkalita 110

its because of the endianness. Read about Little endian and big endian theory.

hmortensen commented: short and on the issue. +1

dkalita 110

Firstly, why is this?

It's because u are defining dictionary in more than one place
Once in wermz.cpp and once in main.cpp

Secondly, why does it say .bss+0x0 and not the line number?

It's the object module which is a binary file and hence it doesn't have a line number

dkalita 110

[QUOTE=bairagi_sattu12;1021479]how i can make compiler[CODE][/CODE][/QUOTE]
google "compiler design"

dkalita 110

here is another good approach
[CODE]

include
include

typedef struct
{
int x;
int y;
}coord;

int bitmaprow=22, bitmapcol=30;
int bitmap[22][30]={
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1}, {1,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1},
{1,0,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,1,1,1},
{1,0,1,0,0,0,0,0,0,0,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1},
{1,0,1,0,1,1,1,1,1,0,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1},
{1,0,1,0,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1},
{1,0,1,0,0,0,0,0,0,0,1,1,0,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1},
{1,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1},
{1,0,1,0,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,1,1,1,1},
{1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1},
{1,0,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1},
{1,0,1,1,1,1,1,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1},
{1,0,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1},
{1,0,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1},
{1,0,1,1,1,1,1,1,1,1,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1},
{1,0,1,1,1,1,1,1,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1},
{1,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1},
{1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,0,1,1,1,1},
{1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1},
{1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
};

int mazesize;
coord *maze;

void loadMaze();
void drawMaze();
int isOccupied(int x, int y);
int main()
{
mazesize = bitmaprowbitmapcol;
maze =(coord
)malloc(mazesize*sizeof(coord));
int x = 21;
int y = 1;
int maxx=bitmaprow;
int maxy=bitmapcol;
int ch;
initscr();
noecho();

    keypad(stdscr, true);
    loadMaze();
    drawMaze();
    move(x, y);
    printw("M");
    refresh();
    int px, py;
    do
    {
            ch = getch();
            px = x;
            py = y;
            switch(ch)
            {
                    case KEY_UP: if(x>0)x--; break;
                    case KEY_DOWN: if(x<maxx-1)x++; break;
                    case KEY_LEFT: if(y>0)y--; break;
                    case KEY_RIGHT: if(y<maxy-1)y++; break;
            }
            if(isOccupied(x, y)==0)
            {
                    move(px, py);
                    printw(" ");
                    move(x, y);
                    printw("M");
                    refresh();
            }
            else
            {
                    x = px; y = py;
            }
    }while(ch!='s');
    return 0;

}
void drawMaze()
{
int i;
for(i=0;i<mazesize;i++)
{
move(maze[i].x, maze[i].y);
printw("*");
}
}
int isOccupied(int x, int y)
{
int i;
for(i=0;i<mazesize;i++)
{
if(x == maze[i].x && y == maze[i].y)
return 1;
}
return 0;
}
void loadMaze()
{
static int isLoaded = 0;
if(isLoaded == 1)
return;
int count = 0;
int i,j;
for(i=0;i<bitmaprow;i++)
for(j=0;j<bitmapcol;j++)
if(bitmap[i][j]==1)
{
maze[count].x = i;
maze[count].y = j;
count++;
}
isLoaded = 1;
}
[/CODE]

dkalita 110

one correction to my previous post:
[QUOTE=dkalita;1015025]do something like:
[CODE]
typedef struct
{
int x;
int y;
}coord;

/store the coordinate of the maze as follows in an array/
coord maze[]={{1,1},{1,2},{1,3},{1,5},{2,3}, {1,4}};
int mazesize = sizeof(maze)/sizeof(coord);/hence u won't need to count how many coords are there manually/

void drawMaze()/draw the maze/
{
int i;
for(i=0;i<mazesize;i++)
{
move(maze[i].x, maze[i].y);
printw("*");
}
}
[/CODE]

call the above function before displaying the M ion the loop.
[COLOR="Red"]correst: call the above function only once in the beginning[/COLOR]
[CODE]
int main(int argc, char argv)
{
int X = 10;
int Y = 10;
int ch;
initscr();
noecho();
keypad(stdscr,TRUE);
drawMaze();/*here***
/
move(Y, X);
printw("M");
refresh();
do
{
ch = getch();
move(Y, X);
printw(" ");
switch(ch)
{
case KEY_UP: Y--; break;
case KEY_DOWN: Y++; break;
case KEY_LEFT: X--; break;
case KEY_RIGHT: X++; break;
}
// drawMaze();/****hereNOT REQUIRED/

    /****FIRST VALIDATE THE MOVE*****/
    move(Y, X);
    printw("M");
    refresh();
}     
while (ch!=27);
endwin();
return 0;

}
[/CODE]

[COLOR="Red"]but now u have to check for a valid move also because that position may be a blockage(i.e. occupied by '*').
So write a function to validate your move and then ony execute the requested move.[/COLOR][/QUOTE]

call the drawMaze() method only once in the start. No need to call it on every move because it will be there at the console already.

panagos commented: ++ +0

dkalita 110

ok ok.
make the following change
(refer to line #19)
[CODE]
if(start==FALSE && spacePrinted==FALSE)
{
putchar(' ');
spacePrinted = TRUE;
}
[/CODE]
change the above codes to
[CODE]
if(start==FALSE && spacePrinted==FALSE)
{
putchar(' ');
}
spacePrinted = TRUE;
[/CODE]

dkalita 110

hi there is already one library method in [B]unistd.h[/B] called encrypt() hence it is giving the problem.
Change the function name to something else like encryptit().
It should work.

Sapreaver commented: Thank you +1

dkalita 110

[code]
if(number = 0){}
[/code]
what do u expect it do do?
That is an assignment statement. Read how to compare numbers.....

U are doing
[code]
number = number%16;
[/code]

u are getting the least significant digit by that and u are loosing the remaining number.
U should have done
[code]
digit = number%16;
number = number/16;
/compare digit now/
[/code]

here is how u can solve your problem in short
[CODE]
void itox(char hex[], int num)
{
int digit;
int i=0;
whle(num>0)
{
digit = num%16;
num = num/16;
if(digit<10)
hex[i++] = digit + '0';
else
hex[i++] = digit -10 + 'A';
}
if(i==0)/if the number was less than 1/
hex[i++] = '0';
hex[i] = '\0';
/reverse the string/
reverseStr(hex);
}
void reverseStr(char str[])
{
int i, j;
char c;
for(i=0, j=strlen(str)-1; i<j; i++, j--)
{
c = str[i];
str[i] = str[j];
str[j] = c;
}
}
[/CODE]

dkalita 110

[QUOTE=surfer2009;1009132]please help for this code. if anyone have it please send me. thanks[/QUOTE]
IMPORTANT:

  1. this is not a code repository.
  2. We help those who show some effort.

dkalita 110

[QUOTE=NinjaLink;1007815]
[CODE]reverseArray(intArray,low,high);[/CODE]
[/QUOTE]
what is the value of low and high. U didn't initialized them.
[COLOR="Red"]Would u plz first go through your code and do a dry run using pen and paper[/COLOR].

dkalita 110

use a flag for that as follows
[code]

define FALSE 0
define TRUE 1

void VymazBiele()
{
int c;
int start= TRUE;
while ( (c = getchar() ) != EOF )
{
if (isspace(c))
{
if(start==FALSE)
putchar(' ');
while ( (c = getchar() ) != EOF && isspace(c))
{}
}
if (c != EOF)
{
putchar(c);
start = FALSE;
}
}
}

[/code]

dkalita 110

[QUOTE=NICEGUY123;1006745]needs to be .rtf because thats what apple uses as its texteditor[/QUOTE]
hi, I have tested it as .rtf also. And its still working.