I wonder a little about this MFC.
In VC++ 2008 Express Edition, is it possible to do this here.
No. That version does not support MFC. You have to get the Pro version to do that.
I wonder a little about this MFC.
In VC++ 2008 Express Edition, is it possible to do this here.
No. That version does not support MFC. You have to get the Pro version to do that.
>>but I can't figure out how that works.
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream in("filename.txt");
string line;
// read each line of the file
while( getline( in, line) )
{
//blabla do something this line
}
}
>>I can't find a way to take a specific line in a text file
You have to read each line one at a time until you get to the line that you want.
>>How can I get each number into its own array?
What kind of array? int array?
#include <fstream>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector<int> arry; // array of integers
ifstream in("filename.txt");
int num;
// read each line of the file
while( line >> num )
{
arry.push_back(num); // add the number to the array
}
}
You are going to have to tell us what's wrong (in detail) before anyone can help you. Just telling us "my program's broke" is like taking your car to the auto repair shop and telling the repairman "my car's broke". We need a lot more information than that.
To pass that array. Note: name in the structure is an array is 5 pointers, not a character array. So that structure can hold up to 5 strings (names).
typedef struct
{
char * name[5];
int number;
}mystr;
int foo(mystr* myptr[5])
{
return 0;
}
int main()
{
mystr* myptr[5];
foo(myptr);
}
2) full it up as you normally would in main()
3) Not necessary ot specifically return the array back to main because when its changed in foo() it will also be changed in main().
That is called a Splitter Window. The only way I know how to do it is with MFC, but I suppose it can be done with pure win32 api functions. Don't know about wxWidgets either.
>>for (i=1;i<=N;i++)
That's a problem. Arrays indices always, always begin with 0, never with 1. So what you want there is this: for(i = 0; i < N; i++)
The same with the other loops.
>>my algorithm have no problem with N <= 4.
Only because you were lucky, not because your code is right.
i always start with stdio.h in my programs (im a newbie),
but now im trying to explore other header files like
iostream.h and im starting there...:)
Forget iostream.h -- use <iostream> (without the .h extension)
>>What I want under my Christmas tree
A new HD 52 Inch TV.
first create a structure that contains the four numbers that can be found on each line
struct nums
{
int stations;
int lbs1;
int lbs2;
int lbs3;
};
now when you read a line, put the data in a structure, then add the structure to an array of structures.
I don't normally quote scripture, but can't help it this time: "Its easier for a camel to go through the eye of a needle than for a rich man to enter the kingdom of God." (Matthew 19:24) That means: I don't give a rats ass about all that much money. I'm perfectly happy with what I have now.
What you are doing is a very aukward and poor design. I think you are approaching this all wrong. why not just use dynamic arrays, such as std::vector, which can contain as many i78tems as you want without resorting to rewriting the function and recompiling the program every time.
If you just want to compare the two lines you don't need to split them into words. Just compare the entire line
std::string line1;
std::string line2;
getline(myfile, line1);
getline(myfile, line2);
if( line1 == line2 )
{
// the two lines are identical
}
war is good -- we spend lots of money that provide lots of jobs. Buy stuff, blow it up, then buy it again. When the war in Iraq ends, all soldiers will go home to no jobs. Oh yea -- we still have wars in Afganistan and up-and-coming Iran. So maybe they will get jobs making stuff to blow up in those two countries. And if Palin is elected she will start a war with Russia, and then we can spend several trillion more dollars blowing stuff up in that country.
I wonder if all those annoying Cirtcuit City popups on DaniWeb are considered spamming?
I have never seen them. Use a popup blocker, or I think you can just go to your CONTROL PANEL and turn them off.
Congratulations, muraliaa! It took you only four years to come up with the same answer as me.
Some people are just a little slow :)
this is a c++ program, so use c++ classes
#include <string>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<string> arry;
ifstream in("filename.txt");
string word;
while( in >> word )
{
array.push_back(word);
}
}
But, in your example while (myfile>>a[names])
should be while (myfile>>a)
An analysis of state-wide records by the Poughkeepsie Journal reveals that 77,000 dead people remain on election rolls in New York State, and some 2,600 may have managed to vote after they had died. The study also found that Democrats are more successful at voting after death than Republicans, by a margin of four-to-one, largely because so many dead people seem to vote in Democrat-dominated New York City. (Link via Ed Still's VoteLaw.)
move your project to a folder that does not contain spaces, such as c:\dev-c++\source
Your program compiles/links ok for me. Instead of powerprof.a you have to link with libpowerprof.a.
The trick is to use fixed c1 << fixed << setw(6) << Total;
You have to make a project then it will work. Just create a new project and copy the file into it.
>>I checked about SetSuspendState() in DaniWeb, and googled it, but came up with nothing.
Not supprised about DaniWeb, but google had lots of links
Always either search MSDN or google for all win32 api functions, and they will give you detailed information. Here is the information you need.
It takes a loooooooooooooong time for it to defrag a hard drive -- expect it to work for a couple hours depending on the size of the hard drive and how full it is. If the hard drive is nearly full then defrag won't be able to do much with it because it needs lots of space to move the data around.
It seems that Senitor HRC was indeed the nation's top oink spender last year.
That totals $296.2 million.
Yup, there's lots of pork on all sides of the fense. Like the Mid America Airport not far from where I live -- its an expansion of Scott AFB (Air Force Base). It was great for Scott AFB, but that's about all. It was originally supposed to suppliment Lanbert International Airport, some 25-30 miles from here, for cargo. But in 8 years not one cargo plain, other than those that belong to Scott. They even built a nice big passenger terminal and other buildings. No passengers since it opened.
One big thing in its favor -- President Bill Clinton landed there once :)
There are differences. You can not copy the registry from XP to Vista or vice versa.
line 338: >> ostream &operator <<(std::ostream &outfile, string &string)
Shouldn't that second parameter be SString& string
instead of string &string
? string is the name of std::string, and you can't use that.
>How the hell did i do this! funny as hell
That's nothing! I'll tell you what would be funny as hell. A new commercial with Bill Gates and Jerry Seinfeld, playing on violin "Fiddler On The Roof", as they hand stand, naked, against the wall. Makes you wonder what they used to play the violin with, doesn't it?
Oh! that would be discusting, not funny. I posted a link to one of their commercial over in Geek's Lounge yesterday. They are anything but funny.
Your program contains millions (maybe even billions) of other errors. What line number are you talking about.
what version of MS-Windows is on your computer ?
I don't know how you did it, but I do know the code you posted can't compile cleanly. For example the loop that starts on line 35 is all wrong. It could be written like this (or use whatever string comparison function you wish).
for(i=48; i<size; i--)
{
if( strcmp(&rev[i], "end") != 0)
{
printf("%c",rev[i]);
}
}
If you are uisng VC++ 2005 or 2008 then you can't use iostream.h at all. That file is obsolete and has been replace with <iostream>
And yes, you can have stdio.h and <iostream> both in the same program.
>>(I have no idea what that means)
time() is a function that's declared in time.h (or in c++ <ctime>). It returns an unsigned integer that contains the number of seconds that has elapsed since some predetermined date -- it used to be Jan 1970, but I'm not sure if that has changed or not.
So the easiest way to seed the random number generator with a unique value is to use the time() function because it will never ever return the same number twice. srand( (unsigned int) time(0) );
srand() is a standard C function so you don't have to declare it yourself. Just call it from the beginning of main(). So change the name of the function that begins on line 15 to something else.
#include <ctime>
int main()
{
srand( (unsigned int) time(0) );
// blabla
}
so a cout needs the three header files to be in effect...
NO. cout only needs <iostream>
#include <iostrem>
using std::cout;
int main()
{
cout << "Hello World\n";
return 0;
}
you also have to change line 40 to be the correct parameter type.
>>I hope it's better explained now.
Yes it does. I think you want hooks into those functions. I don't know the internal function names, but seems like what you need is Undocumented Windows.
He means if argc > 1 then you can assume argv[1] is the filename. But if argc == 0 or 1 then you can assume the filename was not entered on the command line like your example
int main(int argc, char* argv[])
{
FILE* file = 0;
if( argc == 2)
file = fopen(argv[1], "r");
else
file = stdin;
// now use file however you want to
<snip>
// when ready to close the file
if( argc == 2)
fclose(file);
}
You need to study a windows tutorial to understand that. There is no single function. This tutorial will tell you how to add menus to your windows programs.
line 323: According to line 17 length_iter() requires an array of characters. passijng *_string only passes a sincle character, not the entire array. And rstring is not an array of characters, but a reference to a single character.
I think what you want is this:
void SString::operator+(const char* rstring)
{
//string temp();
int len = length_iter(_string) + length_iter(rstring);
<snip>
}
Or you might also want this overloaded function
void SString::operator+(SString& rstring)
{
//string temp();
int len = length_iter(_string) + length_iter(rstring._string);
<snip>
}
I compiled/linked your program without any warnings or errors. Maybe you need to move the source code to a folder whose name does not contain any spaces, such as c:\dev-cpp\source
Its very simple
std::string line;
size_t pos;
ifstream in("filename.txt");
ofstream out("newname.txt");
while( getline(line,in) )
{
while( (pos = line.find('\n') )
line.erase(pos,pos);
out >> line >> "\n";
}
Access is ok for one or two user database, but anything beyond that is just too much. For multiuser you need something like Microsoft SQL Server, or MySQL. For student projects Microsoft Access is IMO an excellent choice.
Can't run utube videos any more because Flash Player doesn't support 64-bit browsers.
After getting the two file names if they are the same open the two files with normal streams then read them one character at a time.
Lines 27 and 28 can only appear in ONE *.cpp file -- doesn't matter which one. Remove those lines from the header file.
Wouldn't it be faster even with dialup to download and burn the ISO instead of waiting for the US Snail?
Yes, but apparently he has a very sloooow dial up computer and downloading that huge file coule be quite costly.
I wasn't aware *compilers* had gui design tools?, I thought compilers were just to convert human readable source code to machine read able code?
So, what's it like for you working in the stone ages :twisted:
Happy Birthday! Actually, it isn't your brithday -- its the celebration of your birthday. You only have one birthday in your life :)
Suggest you re-study the first 8 chapters in your book. Many instructors don't teach directly from the book -- they expect you to read it.