Freaky_Chris 299 Master Poster
inFile >>row >>col;

This is the only line that reads data in from the file, its not looped or anything. This reads 1 integer, then skips whitespace and reads another. The fact that you don't even store them into the array at anypoint, I originally missed!

Also, you should do some error checking to make sure that the file is actually open, using

if(!inFile.good()){
  cerr<<"Unable to open file.";
  exit(0);
}
Freaky_Chris 299 Master Poster

Why don't you have a look at something like QT. It would be a whole lot easier. But yes you could do this anyway.

Chris

Freaky_Chris 299 Master Poster

Looks to me like you only read in 2 numbers from your text file. Then you go ahead and start printing out un initialised memory space....

Chris

Freaky_Chris 299 Master Poster

Does the link know where and to include C headers etc....

Just link it with gcc using gcc example.obj -o example.exe

Freaky_Chris 299 Master Poster
Freaky_Chris 299 Master Poster

<> state the file is located in the include directories.

"" states it may be located in the same location as the main source file.

(something like that) You need all the files in the same Project / Tell your compiler to compiler all 3 together :)

Chris

Freaky_Chris 299 Master Poster

When doing this, the method is normally to have aheader file containing the function prototype. A Cpp file containing the function declaration and the a main cpp file that contains your int main(int argc, char *argv[]){} function, etc etc.

//example.h
#ifndef EXAMPLE_H_
#define EXAMPLE_H_

int myfunc(int, int);

#endif
//example.cpp

#include "example.h"

int myfunc(int x, int y){
  return (x*y)-(x+y);
}
//main.cpp

#include <iostream>
#include "example.h"

int main(int argc, char *argv[]){
  std::cout << myfunc(12, 2);
  return 0;
}

Chris

Freaky_Chris 299 Master Poster

Instead use this:

cin.ignore(cin.rdbuf()->in_avail());
cin.get();

An even better way would be run it from your console/command prompt! Since it's a "console" application!

And DO NOT use system("PAUSE"); . Not only is it non-portable, but its also a VERY expensive system call!

You should probably read the Sticky "How Do I Clear the Input Buffer?"

Chris

Freaky_Chris 299 Master Poster

Store the points at which you have something drawn on the screen in an array/vector or what ever you feel is best.

Freaky_Chris 299 Master Poster
ostream& operator<<(ostream& os, Book& b){
	cout<< "Title: " << "\"" << b.title << "\"" << endl;
	cout<< "Author: " << b.author << endl;
	cout<< "Genre: " << b.genre << endl;
	cout<< "Publisher: " << b.publisher << endl;
	cout<< "Publication Year: " << b.pubyear << endl << endl;
	return os;
}

This is wrong! How do you know that when the << operator is being use it is to the cout, you should be applying it to the stream you are given 'os' you have named it! Not going straight to cout.

Please read about these things :\

Freaky_Chris 299 Master Poster

What exactly is the problem? this works fine for me....nvm

EDIT:
of you need to loop through each character rather than just using the first one

Chris

Freaky_Chris 299 Master Poster

What exactly is the character problem, '1' + '1' does = 'b'. What is your decode function is it not, 'b'-'1' = '1'.

Or did I miss something?

Chris

Freaky_Chris 299 Master Poster

Sorry if I come across rude. Yes alot of people do it, and they also get a LOT of stick for it thats for sure.

Chris

Freaky_Chris 299 Master Poster

Well, so far, nobody replied. But if I am freaking out someone I can remove it. Why is it a waste of time? And, if you consider it a waste of time what are you doing here? Are you being paid or something? :)

This is my point, we are not paid. This means we volunteer out time to help provide you with a solution in which somebody on another site is already discussing in his/her own time. Meaning the same topics get covered multiple times on different forums wasting more peoples time. No doub you will find somone such as Salem is a member of both forums, and he may well refuse to post in either, despite the fact he is perhaps one of the most valuable people to you.

If we were paid we wouldn't care

Chris

Freaky_Chris 299 Master Poster
encryptedLine += (line.at(pos) + password.at(pos2));

if (pos2 > password.size())  {
	pos2 = 0;
}

You try to retreive the value at pos2 when pos2 is > than password.size() before you reset pos2 to 0. Also the check should be >= or == since if the length of string is 12, then the pos2 will need to be 13 to reset, yet you only get 0...11 index on your string.

Chris

Freaky_Chris 299 Master Poster
Freaky_Chris 299 Master Poster

So who do you want to answer it or are you happy wasting the time of two sets of people?

Chris

Freaky_Chris 299 Master Poster

Well, yeah, I did it with notepad - still:

"error C2065: 'POPUP' : undeclared identifier"

Start a new thread, now this is marked as solved and it's technically a different problem. Remember to use code tags and post the problematic code.

Chris

Freaky_Chris 299 Master Poster

omg, I am using Visual C++ 2008 Express Edition
"Resource Editiong is not supported on the Visual C++ Express SKU"
:( Thanks anyway.

EDITING is not supported, you can still use .rc files lol, just if you want to use VISUAL resources then you have to make the in external application and import them

Freaky_Chris 299 Master Poster

AH now I see why, you haven't included your header file into your main cpp file #include "yourheaderfile.h" :D

Freaky_Chris 299 Master Poster

OK lets goover what i've done.

#include <sstream>
#include <fstream>

int main(int argc, char *argv[])
{
	std::ofstream outfile("data.txt", std::ios::in);
                std::ostringstream output;

	for(int count = 1; count <= 1000; count++)
	{
            output.str("");
            output << count;
            outfile << output.str() << "^" << output.str() << "+" << std::endl;
	}

	outfile.close();
	return 0;
}

Sorry, you didn't want clear(), it was str("") you need. Anyway you can see i've made a few changes, such as removing un-needed headers, taken out namespace std; .
Dropped your capitals name convention, 'cause it's horrible.

Then I went and decided that you don't even need stringstreams and I'm not sure why you are using them.

#include <fstream>

int main(int argc, char *argv[])
{
	std::ofstream outfile("data.txt", std::ios::in);

	for(int count = 1; count <= 1000; count++)
		outfile << count << "^" << count << "+" << std::endl;

	outfile.close();
	return 0;
}

Chris

Freaky_Chris 299 Master Poster

Can't see exactly what you are doing wrong, partly because i prefer having function definitions split from the class prototypeing.

However you have a function void book() now, i'm curious as to what this is supposed to do, since you never call it; yet it looks to me as though it should be called immediately, I.E as the constructor. If it is supposed to be the constructor then shouldn't it have the form Book() .

Also you are working with alot of pointers and you have no descutor which is freeing up memory, I have a feeling this is going to lead to memory leak heaven!

Chris

Freaky_Chris 299 Master Poster

it's your string stream, you need to clear it before adding more to it.

OUTPUT.clear()

Chris

Freaky_Chris 299 Master Poster

Store what has been drawn by the user somehow, then redraw it :)

Freaky_Chris 299 Master Poster
Freaky_Chris 299 Master Poster

I though that it also breaks out of the loop when there are no more characters left in the buffer, as well as breaking when it reaches a newline delim. Thus it would remove all characters and then break out of the loop leaving the input stream empty with or without a line break?

Chris

Freaky_Chris 299 Master Poster

Well if one was to hide the console window and paint on the main window / active window you could use it in conjunction with something like presentations as a pointing aidor something like that.

@marco
Thats like saying you should do all DirectX Drawing inside WM_PAINT :)

Freaky_Chris 299 Master Poster

All header files are taken from the include directory. May be the compiler is not responding because your newly created header file may not be in its search path.

when wraped in double quotes it is taken that the header file may be located in the same directory as the source file

Freaky_Chris 299 Master Poster

Can I draw your attention to this snipped post by Narue in the input stream clearing thread

#include <istream>

void ignore_line ( std::istream& in )
{
  char ch;

  while ( in.get ( ch ) && ch != '\n' )
    ;
}

Chris

Freaky_Chris 299 Master Poster

Be sure to make sure all of the files are in the same project, not indervidual just indervidual files, otherwise the compiler will not know to use myfile.c.

Chris

Freaky_Chris 299 Master Poster

A) We do not do work for you.
B) Do not use "Fakse" Signatures
C) Do not advertise
D) Read the forum rules
E) Come back after doing these with a code attempt.

Chris

Comatose commented: Exactly +10
Freaky_Chris 299 Master Poster

I am sure the "dic.dat" is in the same directory with the source file,
moreover, I tried the expression
if(!inClientFile.good())
but it didn't seem to work.

Lets say you are compiling with VC++ then your source code isn't in the same location as the debug or release exectuable, which means nore will "Dict.dat" be, this means you will need to move your Dic.dat file into the debug/release folders.

Chris

Freaky_Chris 299 Master Poster

You need to make your constructer call for the Movie class match the constructor definition for starters.

Your displayInfo() and searchList() functions in there prototype do not state they accept an array of of the structure Movie, but they do in their definitions.

Chris

Freaky_Chris 299 Master Poster

Please use [code=cplusplus] [/code] tags.
You need to learn how to call functions since from what I can see you have no idea. I suggest going over the basics again before attempting to carry on.

Chris

Freaky_Chris 299 Master Poster
void *malloc ( size_t size );

This is the function prototype, and as Agni stated it returns a void pointer. Since this is the function prototype you do not use this syntax when calling the function and infact you use the syntax you originally posted. Here is a small example

int q = 34;
char *test;
test = (char*)malloc(q);
...
free( test );

The snippet above will create a character array (c-string) of length 33, since 1 space is need for the null terminator. Be sure to read about the use of free(), it's essential!

Chris

Freaky_Chris 299 Master Poster
if(!inClientFile)

Please do not use this method, it is so wrong. You would be better using the following

if(!inClientFile.good())

Chris

Nick Evan commented: Holy s***, I completely missed that :( +12
Freaky_Chris 299 Master Poster

srand((unsigned)time(NULL)); is what most people use if I am correct, I know for sure I have always used it and always will, unless someone puts forward a good argument not to use it.

Just remember you only need to call srand() once in your application.

Chris

Freaky_Chris 299 Master Poster

Muhammad so do you, firstly you havn't used code tags, secondly comments '//' * '/* */' are useful for commenting code.

When found is a bool, then if(found) is fine.

Chris

Freaky_Chris 299 Master Poster

Read the forum rules, read a C++ book, read previous threads, just read something!

Chris

StuXYZ commented: lol @ "just read something" +5
Freaky_Chris 299 Master Poster

for your q1 this is the code that will reverse the digit.. 3 integers, you should modify this to 5 digit..

temp=x;
x=z;
z=y;
y=temp;

This is a bad solution, you should not do it this way as this relies on you know A exactly how many digits will be entered at compile time. Plus it wouldn't be quite that simple since 363 would correspond to x, and x y and z.

Please rad Stu's post, it explains how to do it perfectly.

Chris

Freaky_Chris 299 Master Poster

should be static char *month[12][25]; Chris

Freaky_Chris 299 Master Poster

Think about all the things you have been taught in you're course so far. Think about where you excel in programming then develop smaller projects you have already completed into a monster project. That way you won't be wondering completely into the dark....

Chris

Freaky_Chris 299 Master Poster

Solution has been sent to you ... however i didnt compile the code, but it will work, i just forgot to set the boundries of array and hope that u will do it by using a nested while loop of if condition, when u try yourself.

Have a happy programming :)

Please don't PM code solutions. I suggest re-reading the forums rules too. Just to make sure you understand how we work when it comes to handing out code.

Secondly, code solutions are best in the thread they are the solution for. So in the future people are able to search for solutions to problems and find it. Rather than having to start a new topic, waste more peoples time purely because some goon wouldn't share a solution.

Chris

Aia commented: Yes. +13
Freaky_Chris 299 Master Poster

What do you mean by 'Text'? As in an editable text control? or just writing painted onto the windows?

there is a big difference.

Chris

Freaky_Chris 299 Master Poster

it's code=c++ btw no need for language, I wasn't exactly sure what fsync() required. But i had a feeling that it would give you ideas.

I did say it was crazy XD

15 min edit grace period use it please.

Freaky_Chris 299 Master Poster

char name[5]; 5 is the number of elements you get 0..4

Chris

Freaky_Chris 299 Master Poster

Whats the exact error, thats the easiest way :)

Chris

Freaky_Chris 299 Master Poster

OK.
Your array should be initialized to null terminating chars and when printing out would should print all of the characters upto the first null terminator rather than all 250.

So you will need to check if the array position is equal to '\0'

Chris

Freaky_Chris 299 Master Poster

Would you not be better of using strings in the modern world of C++ or is this an assignment?

Sorry to ask this just don't wanted to go into this method if we can just use strings :)

Chris

Freaky_Chris 299 Master Poster

crazyness but

fsync(fileObject.rdbuf())

would it not be something silly like that?

EDIT: Nevermind previous was a much better answer[/EDIT]