then your guess would be wrong.
Wouldn't be the first time :)
then your guess would be wrong.
Wouldn't be the first time :)
if you're gonna pass the address of the variables as stated in line 23:
void yrCalc(int totalDays, int& year, int& month, int& day)Your variables should contain also their address in line 16:
yrCalc(40000, &year, &month, &day);
Not so -- you are thinking C, not C++ because yrCals() does not take pointers.
if you use the algorithm
std::search
with a predicate, the string does not have to be transformed.
But the same letters have to be transformed many, if not hundreds, of times depending on the length of the string. Consequently, my guess is that transform() and then find() is faster than search()
A billion dollars a day (not to mention a thousand American lives a year) is a ton of money to waste on a tiny country half way around the globe. We could easily pay for national medical care for everyone with that money and have lots of money left over for other things.
line 23 should look like this: void yrCalc(int totalDays, int& year, int& month, int& day)
If you do that then you also have to change lines 25-28 to use the valid variable names shown above.
tolower isn't in std:: namespace. And its defined to return an int so it isn't necessary to typecast it. You might have to include <ctype.h> std::transform(stringToSearch .begin(), stringToSearch .end(), stringToSearch .begin(), ::tolower);
giving new programmers "malloc" is like giving them rope to hang themselves with or a gun to shoot themselves in the foot with.
malloc() is only one of may may ways newbes can kill themselves. Just because you don't own a gun doesn't mean you can't slit your wrists or jump over a cliff :)
even experienced programmers should avoid the use of malloc unless absolutely necessary. which it usually isn't.
My guess is that you have not done much professional programming.
declare the local "tmp" string in the subroutine as a char array of some length, and do a check for the strlen( ) of the input argument if you want a check.
That will rarely work correctly. You might get lucky but there is no guarentee that the array won't be big enough. Sure you can use strlen() to check on the length of the string and not do anything if the buffer isn't big enough, but that doesn't solve the problem. The only way to guarentee the new buffer is big enough -- without declaring very huge arrays -- is by using malloc() to allocate anough memory.
better yet, don't have the subroutine even make a copy, just modify the string that is passed into the function in place. if you need to keep an unmodified copy of the original, have the caller (main) make and keep the copy.
We don't know the program requirements. That will work as long as its not a …
line 23: you are attempting to give each of the variables two names -- delete a, b, c and d then leave all the rest.
there is stricmp() C function, but there is no c++ equivalent. convert the string to all upper or lower case then search it.
string stringToFind = "number[";
string stringToSearch = "something Number[1]";
transform(stringToSearch.begin(),stringToSearch.end(),tolower);
stringToSearch.find(stringToFind);
I would just reformat the hard drive and start all over again with a new install of Vista. Hope you have the disks :)
Guys, isn't it time we started a new 2008-specific section?
Why? there is no such operating system.
so no change from bush then ;)
Absolutely, which is one reason I won't vote for him. We don't need another 8 years of Bush.
I read that McCain hates the UN ...
So do I -- the UN is a worthless piece of crap. We should toss their butts out of the USA and unjoin it.
template and inerentence at two completly different animals. You would use one instead of the other at any time. I'm not great on templates but I think templates can experience inherentence just as normal classes can.
Add the encrypt *.cpp file to your MFC project then compile and link just as you have the rest of the program. In the OnClick() event handler for the button just call your emcrypt function as you would any other function.
Not able to unzip the attachment with WinZip.
remove the brackets from the last parameter -- it should not be an array int searchList(string array[], int numElems, string value);
see line 10: it has the wrong prototype. Compare it with line 25 which is correct.
just like generating any other random number. If X is the number of columns then int col = rand() % X;
I was 42 when I retired from the USAF in 1985 and began my programming career. First got an intro job for a temp agency in St Louis then a contracting company. In 1997 landed a job for a company that had a large government contract in my area -- probably 50% or more of the employees were people over 50 (about 200 employees). I was only out of work for 1 day when I got that job and I didn't know anyone there either :) I never found it difficult to find work at my age in the St Louis area.
I'm totally stuck!!
Get out the lard and grease up to that you can get unstuck :)
line 12: Since temp is an uninitialized pointer this line will most certainly crash your program. You have to allocate memory using malloc() before starting the loop on line 10. Line 8 should read: char *tmp = malloc(strlen(string)+1);
.
line 7: You don't need to save the pointer string, you need to make another copy of the pointer tmp after it has been allocated by malloc().
char *tmp = malloc(strlen(string)+1);
char *p = tmp;
// rest of your code here
line 25: you need to call free() to deallocate the memory that is returned by the convert() function
>>I think I understand creating a multiplication table without an input
Not much different. Post how you would do it without input and we'll show you what you need to change to make it work with input.
Welcome to DaniWeb. Please feel free to post questions and comments in the appropriate boards.
moved
The only way to get the exact row count of the number of rows returned by a query is to count them as they are retrieved. Before starting to retrieve rows the db server knows whether or not there are more than zero rows, but doesn't know exactly how many until they have all been retrieved.
You forgot to tell us what is the problem -- sorry but I'm not a mind reader.
you need a loop and the macro toupper(). For example of how to convert a single character to upper case please read the related thread that appeared immediately next to the one you created.
>>I tried them but i cant seem to get them to compile
post the code you tried.
>> strcpy(view[place.y][place.x],"s");//says that the problem is here[/b]
That is just a character, not a pointer. same as attempting to do this: strcpy( view[0][0], "S");
If all you want to do is replace the single character then use the assignment operator, not strcpy(); view[place[i].y][place[i].x] = 's';
If you upgrade to Vista there are a lot of programs that ran on XP that will not run on Vista. If you like to play a lot of games on XP then check with the manufacturer(s) of your favorites before upgrading. I have to duel-boot back to XP in order to play some of my games.
The ultimate edition is pretty nice, but not worth the price unless you do a lot of web programming or want to use it as a server for other computers. Otherwise the Home edition works just fine for most other people. And mine works just great with 2 gig ram
>>If you go all the way to 4GB, remember to use 64-bit Vista
Before you buy it make sure you can get the drivers for it. I tried 64-bit XP for a few hours and removed it due to lack of video and other drivers. Maybe Vista resolves that problem, don't know.
Another version
void capitalizeFirsts(char *buf)
{
while( *buf )
{
while( isspace(*buf) )
buf++;
*buf = toupper(*buf);
while(*buf && !isspace(*buf))
buf++;
}
}
>>substr(0, rfind("[")+1)
Don't even attempt to do that because it might crash the program if rfind returns string::npos (-1). Better to split it into two lines so that you can do error checking
size_t pos = line.find('[');
if( pos != string::npos)
{
int x = atoi( line.substring(pos+1).c_str());
}
Creating separate *.cpp files will work, but I think its overkill in your project. And unless you were specifically instructed to create separate files I don't think you should do it. All you have to do is write those functions after the end of main()
Are you looking for a function that takes a variable number of arguments such as printf() ? void foo(int a, ...);
Look up varargs.h and associated functions.
Its pretty easy to extract the number between the square brackets, but why? put the number in a std::string ?
std::string has a replace() method that you can use to replace one substring with another.
Tobble: Hitting a key that makes all the characters act like they are drunk.
Ohhhh. I get it now :) :)
>>but still i dont know how to fix the warning
Should be obvious -- put a return value at the end of the function. Once the loop ends the function is supposed to return something, but you forgot that instance. I think you can delete lines 65-68 and just return TRUE outside that loop.
typecast it
float n = 123.45F;
double x = (double)n;
or
double x = static_cast<double>(n);
>>//why this doesnt have sizeof? =)temp->name=(char*)malloc(strlen(tempString)+1);
>>//this is based on the linked list example 1(above)
>>//why this doesnt have sizeof? =)
It doesn't use sizeof(tempString) probably sizeof(any pointer here) is only 4 on 32-bit machines while the length of the string can be much much more than that. And the size of a character array may or may not be the same as the length of the string in the array.
char str[255] = "Hello";
in the above, sizeof(str) is 255, but strlen(str) is only 5.
Hummmm. Seems your function needs a tad bit more work. But its close.
int main()
{
char str[] = "now \tis the time for all good men\n";
capitalizeFirsts(str);
puts(str);
return 0;
}
Results
Now is The Time for All good men
Press any key to continue . . .
You are getting those errors because you didn't write those functions yet. The three lines just before main() are not functions, they are just prototypes, which tell the compiler about the return value and parameters. You still have to write all the code that makes them do something.
>>capitalize the first letter of each word they type in,
One way to do it would be to use strtok() to find each work then toupper() to change the first character to upper case. strtok() modifies the original string so you will want to make a copy of the string before doing anything with it.
It can't be done in MS-DOS either because there are no email servers for that os.
>>What topics or lessons should i master
All of them. Buy a book Introduction To C++ (there are lots of good ones) and start studying from page 1.
do you have to write your own linked list or can you use ready-made such as <list> ?
Isn't the information about files and lists in your textbook? Did you read your textbook?
>>help me to do operator overloading n class
Does that mean you want us to write that class for you? If not then you need to post the class that you have written. If it does mean that then sorry but you're out of luck here because we don't do your homework for you.
The text is not copied into the pointer. The pointer just points to a memory location in the character array that is passed in the first call to strtok().
>>I jsut want to know how can I improve from line 46-60.
I already showed you that. If you can't use vectors then the way you did it is about the only available solution. You could rearrange the code something like what I already posted.
The real question to ask is, "Why is government taxing people below the poverty level?"
In USA? They aren't taxed and they pay no income taxes, but of course they pay other taxes (consumption taxes) just like everyone else and in some cases they don't evey have to pay that. Here in Illinois there are certain not-for-profit community homes which can get tax exempt cards so that they can buy food, clothing, etc with no tax. There's one such home in my area for people with cerebral palsy.
line 14: you have to specify the name of the Student object, not just the data type float calculateGrade(Student& stu)
When writing inline functions like that one you must always given the parameters both data type and variable name. In this case I would make it a reference to a Student object so that the compiler doesn't have to duplicate it when it is passed.
Sorry AD. In another thread you added line numbers to my code so I tried to add them, but used the wrong button.
All you have to do is add the language to the code tags
[code=cplusplus] // put your code here
[/code]