|
Hi, I need to read 5 rows by 5 columns of numbers from a text file into a 2D integer array.
How do I do it in C++?
e.g
10101
00011
10111
01110
10010
I've already created a 2D array and the necessary statements which are used to read from a text file.
i.e
int data[5][5];
ifstream inClientFile("Data.txt", ios::in);
|
|
|
|
|
first read all data in any string then reterive useful text from it!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
And it seems he needs to convert string to int atoi
|
|
|
|
|
How to create a setup.exe to install MySQL_5.0.exe and MySQL_Query_Browser.exe in a single click?
MySQL_Query_Browser.exe setup must start after the complete installation of MySQL_5.0.exe .
can any one help me ?
Thanks in advance
JAYARAJ
|
|
|
|
|
J5121982 wrote: ow to create a setup.exe to install MySQL_5.0.exe and MySQL_Query_Browser.exe in a single click?
download INNOSetup!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
Hello everyone!
After working out a bit since my last post (don't worry - you don't have to read it to understand this one...), I got some different errors... It tells me I've redefined 3 specific symbols 6 times each... 2 of them are on one file, one is on another file... The include guards all seem correct, I can't see what's wrong... Hm, I've been thinking it could be the way I include files - I made a Includes.h file that includes all my headers plus all the C++ headers I need and I include that in all my headers... Maybe that's the problem? Here's the file:
#ifndef _INCLUDES_H_<br />
#define _INCLUDES_H_<br />
<br />
#include <iostream><br />
#include <string><br />
#include <stdlib.h><br />
#include <time.h><br />
#include <vector><br />
#include <string><br />
using namespace std;<br />
<br />
#include "SDL.h"<br />
#include "SDL_image.h"<br />
<br />
#include "Defines.h"<br />
#include "Structures.h"<br />
#include "HelperFuncs.h"<br />
#include "Vehicle.h"<br />
#include "ErrorHandling.h"<br />
#include "MapHandling.h"<br />
#include "Player.h"<br />
#include "Game.h"<br />
<br />
#endif // _INCLUDES_H_<br />
Can anyone tell from that what the problem is, or should I include some more code? Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
Can you show exact error message ?
|
|
|
|
|
|
|
Have you placed include guards in all your header files?
|
|
|
|
|
Yes sir... Weird, huh?
Windows Calculator told me I will die at 28.
|
|
|
|
|
Hi all,
I am having runtime crash with code below
int main(int argc, char** argv)
{
vector<int> iVec;
iVec.push_back(0);
iVec.push_back(10);
iVec.push_back(20);
iVec.push_back(30);
iVec.push_back(40);
iVec.push_back(30);
iVec.push_back(60);
vector<int>::iterator it;
for(it=iVec.begin(); it != iVec.end();++it)
{
if(*it = 30)
{
iVec.erase(it);
}
--it;
}
return 0;
}
How can I get all "30" out?
Thanks!
Yonggoo
|
|
|
|
|
for(it=iVec.begin(); it != iVec.end();++it)
{
if(*it = 30) // May be this is the problem
{
iVec.erase(it);
}
--it;
}
the above if line is the culprit if you typed it so in your code also
it should be
if(*it == 30) // corrected
Tanvon
the brain behind ...
I Blog here
|
|
|
|
|
I'm not getting any crash with your code ?
|
|
|
|
|
I'm trying to set the font in a list box, however, I can't find the documentation that dscribes or lists the fonts. The best I have found is that CWnd::SetFont takes a CFont* parameter. OK. So what does the CFont* point at?
void SetFont(CFont* pFont, BOOL bRedraw = TRUE)
So I wrote:
CFont* ptFont = ?????:
m_ListTrans.SetFont(ptFont, TRUE)
Any guidance is appreciated.?
|
|
|
|
|
First of all create a font then set it for listbox
creation of font is easy through CreateFontIndirect()
1: create a member variable of CFont ( mFont )in your class
2: then create font.
LOGFONT lf;
memset(&lf, 0, sizeof(lf));
lf.lfWeight = FW_NORMAL;
lf.lfQuality = PROOF_QUALITY;
lf.lfWidth = 20;
lf.lfHeight = 24;
mFont.CreateFontIndirect(&lf);
3: Now you can select that font in listbox
CFont* ptFont = &mFont:
m_ListTrans.SetFont(ptFont, TRUE)
Tanvon
the brain behind ...
I Blog here
|
|
|
|
|
|
<br />
CFont m_Font;<br />
m_Font.CreateFont(...);<br />
m_ListTrans.SetFont(&m_Font, TRUE);<br />
|
|
|
|
|
I'm making an appliaction that generates a timeline using open gl to display the graphics. At one time I had open gl do a translation based on the mouse position. However it was not turning out the way I wanted it to, and the project needs to be done by Monday. So i decided to throw it out and just use scroll bars since its only 2D.... and the scroll bars work.... almost.
My problem is that when you drag the scroll bar everything works right, but the second you let go. The bar goes back to 0. I'm curious what i need to add, or change so that the bar keeps its position when you let go of the bar.
C++ using MFC in visual studio 2003. If you need any thing else to help me debug send a line. I'm in the office until 5, so if you need some source code i can have that when i get home Thanks for the help,
Steve
|
|
|
|
|
you probably need to call SetScrollInfo on the scroll bar that moved, to set its position.
|
|
|
|
|
You need to handle the WM_HSCROLL or WM_VSCROLL message and set the thumb position. While you are dragging the thumb you will get SB_THUMBPOSITION notifcation messages, simple set the scroll position when that happens.
Regards,
Alex
|
|
|
|
|
Image distortion algorithms are hard to find, and c/c++ examples are very rare. I am rendering a ripple effect (stone into a pond) onto a bitmap. The algorithm itself is quite easy yet I have noticed an annoyance (and also noticed it in every example I have found.
When the bitmap is distorted the top and bottom is pulled away from the edge, revealing the origional bitmap beneath, also the left and right edges are 'how to say' wrapped around, ie the void space is filled using pixels from the opposit edge. I know that GIMP allows the option of either filling the void with the opposite edge, or filling with a brush. But both of these solutions don't look realistic.
I'm open to suggestions.
|
|
|
|
|
waldermort wrote: But both of these solutions don't look realistic.
what should happen ?
if the source data is being pulled towards the center, it seems odd that it should also be pulled outwards, to fill in holes.
one option is to let the ripple happen as the math demands, but then crop the output to get rid of the problem areas.
in my stuff, i like to fill the blank areas with pixels from the edge of the source.
|
|
|
|
|
you could enlarge the source image by wrapping the opposite edges some ammount of pixels, so that you ripple a larger image, but it will be clipped to the source image size; but you might have some problems with the corners
Attempt to some ASCII art drawing showing what I mean :
source image
+-----------+
| |
| |
| |
| |
+-----------+
enlarge source image
aaaaaaaaaaaaa
aaaaaaaaaaaaa
+-------------+
yy|xx yy|xx
yy|xx yy|xx
yy|xx yy|xx
yy|xx yy|xx
+-------------+
bbbbbbbbbbbbb
bbbbbbbbbbbbb
does that make sense ?
|
|
|
|