~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

For example, the latest version of Visual Studio complains that the Standard Template Library is "deprecated", which is total crap.

Didnt know about this one but it does the same thing with scanf( ).

Maybe it is hoping to create its own C++ standard within the actual standard, and whats more its actually encouraging newbies to use the non portable functions and headers( stdafx ?).

Maybe we should post a sticky at the top of forum saying "Don't listen to MS's crap". :D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe one of his friend was Mr. DMR (yeah who knows...) :D
.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ah...I thought maye you had changed the code and the OP had totally missed it...maybe i was wrong ;)

Looks like you can't trust anyone these days... :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Did you do exactly as you were told:

# include <stdio.h>
# include <stdlib.h>
# include <string.h>
 
int main()
{
  FILE *in_file;
  char dataFile[20] = { '\0' };
  char date[20] = { '\0' };
  char operator[30] = { '\0' } ;   // you're using a C keyword!
  char ts[80] = { '\0' } ;
 
  printf("Enter file name");
  scanf ("%s", dataFile);
 
  in_file = fopen(dataFile, "r");
 
  fprintf(in_file,"%s %s", date, operator);
  fgets(ts,sizeof(ts), in_file);
  
  if ( strstr(ts,"Vendor Setup") != NULL) // missing bracket
  {
      printf("Data found");
  }
  
   return 0;
}

More importantly, do you have a file with the name which you are entering ? And does it contain data in the specified format ?

Make all these things sure first and then repost if necessary.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What have you attempted till now ?

There are many examples in the forum on the same topic, you can go through them.

One of them is here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Since I dont know with which option you would be more happy, i ticked each of them. Maybe should liven up the poll and bit.

But if it were a poll with option buttons( and not checkboxes ), I would have definately supported you Mr. DMR since I dont think they bother a lot of people.

PS: The poll which you rigged really was a good one, though it was against the rules, it sure was fun while it lasted...got the OP flabbergasted..:D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I like 0. Because being a pessimist it goes well with the pessimistic image. Zero is zero and nothing but 0.

Well actually if you will notice that there is quite a bit of history and controversy associated with it.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yeah gets hold of all the image elements on the page in an array and starts manipulating the properties like its x and y coordinates.

But still its the idea that counts, good one.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

But still we can surely aim for a "game development" message board, can't we guys....;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Don't use void main . It's old and outdated, and so instead you should use int main .

void main( ) never was a C / C++ standard right from the interception of the language.


main() must return int. Not void, not bool, not float. int. Just int, nothing but int, only int.Some compilers accept void main(), but that is non-standard and shouldn't be used.

Even if the program with the misdeclared main() "works" (that is, compiles without error, and runs without crashing), it does result in a garbage (random) exit status being returned to the calling environment. You or your command invocation environment may not be noticing that particular glitch right now, but it is a glitch, and it may bite you later.

Hope it cleared the matter.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Also MasterBlast, use code tags to post your code since it makes the code easier to read as well as the formatting is maintained.

Read the forum announcements.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you have Win98 I think it can be done. Just run your program and press "Print Scr" button on your keyboard, minimize the Turbo C window, goto MSPaint and paste the image.

It should work out to be fine, but dont know if the same can be done in WinXP. Here you can try out ALT + Print Screen, though I have not personally tested it.

Another way is to press ALT + ENTER when you are in full screen mode of Turbo C to resize the window, then you can use comfortablly use PRINT SCREEN button to capture the whole screen, edit out the part which you require and print it.

One of this is sure to work and if not then dont think anything else will.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I know it was wrong and was going to edit the post but dont know why it works in my case....

Just wanted to make someone double cheked it because it works in my case( dont know how ).

Mr. Dragon, if you have a VS2005, can you please check it out because Jobe has I think got a VC6.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Okay looks like something queer is going on around here. I ran the same program without any modifications and this is what I get:

January
February
March
April
May
June
July
August
September
October
November
December

Press ENTER to continue.
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

@ AD,
Thanks AD, but, I thought that begin and end also worked with strings no?

Iterators work only for C++ containers. String, Vector etc. are containers and iterators work well with them. Array is not a C++ container class. You can use iterator to walk through the characters of the string..

@ s.o.s,
That doesn't work s.o.s, I think it's because strings are not \0 terminated.

If you will look closely, I have done "str != 0", here str is a pointer. The above code works perfectly well for me.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

How about something like:

for( const std::string* str = myArray ; str != 0 ; str++ )
        std::cout << *str << '\n';
    std::cout << '\n';
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Here is the game in some another language, you can understand it and try to convert it to C / C++.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hello there Miss, welcome to Daniweb.

Hoping to see you around here....:D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Do you realize that this is called as a spam attack and is not legal ?

Basically what you are asking for are scripts which sift through websites and finds mail addresses and mails them.

This is normally the principle on which search engines are based on, but using it for your personal gain....

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It does not mean the user can input as many strings it means that at the time of declaration of your array of strings you can initialize it with as many strings there as possible and the compiler will figure that out for you.

It also tends to save space as compared to the normal method of creating a two dimensional character array.

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

My pleasure....also one more thing to point out.

The entry point of the program i.e. main( ) returns int so the correct way to write programs would be

int main( ) 
{
   // write your code here
  return 0 ;   // dont forget to return program status
}

Also dont use getch( ) its non standard, use getchar( ) to achieve the same purpose ie stopping the screen.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You have declared prn_random_fcookie( ) as prn_random_fcookie( char ) ; while you have defined it as

prn_random_fcookie( )
{
   // you code here 
}

As you can see the declaration and definaton dont match.

Also what you need to do is to pass the function nothing, calculate a random integer between 0 to 4 (since your string array has 5 strings ) in your function itself and use that integer to print out a random string.

Also it would be better if you declare the array of strings as

char* fc_array[] = { "Everything will now come your way.",
                                  "Now is the time to try something new.",
                                  "A handful of patience is worth more than a bushel of brains.",
                                  "You have an active mind and a keen imagination.",
                                  "Don't let doubt and suspicion bar your progress."
                                } ;

since this method helps save space and letst the compiler take care of things for you.

You need to write in your function somethign like:

int random = rand( ) % 5 ; // generate random between 0 and 4
printf( "%s", fc_array[random] ) ; // use that random to index your string array

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Looks like but I think atleast one for loop can be reduced...

Assign the values to the structures members in the for loop in which you display the result of your first attempt ie loop 1.

for( int i = 0; i < 12; ++i )
{
    std::cout << "From first method: " << days[i] << " " << month[i] ;
    dt[i].strMonth = month[i] ;
    dt[i].strDays = days[i] ;
}

Hope it helps.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Welcome to the site.

Yeah and even we are game so bring it on.....:D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ditto, maybe when it is morning at your place the other mods (especially Mr. WaltP) will take a look at this thread and give some valuable feedback.

Good night Miss Dani.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The problem is that I can't use red because I didn't like having numbers, strings, and characters all in one color as in WaltP's example, so I made numbers red.

Firstly ... everyone keeps giving me different suggestions to color everything and confuses me!! Secondly ... that example doesn't highlight functions which would be the purpose of changing color to begin with.

The example which I quoted was to do away with the confusion regarding numbers, strings, characters and other literals so that the color red would then be free to be used for functions...

Its bad that Mr. WaltP is offline right now , since you seem to be making the color scheme based on his base scheme. But still it wont hurt to let this discussion for a while, while each and everyone posts his choices.

After all it wouldnt hurt to take ideas from different places and see which works better for our site. There is no hurry as such( methinks ).

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That wont be a problem if you assign some different color to them..

Here is a sample which you can have a look at:

[IMG]http://img143.imageshack.us/img143/1455/untitledle5.jpg[/IMG]

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

C/C++ functions don't need to be colored, but if they are, use a dark color like maybe red

Yeah even I think that the functions should be easily distinguished from the normal statements and constructs.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Looks good from what little I have seen.

All the imporatant features of the program like keywords, curly and round braces have been emphasized.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

at the castle-gates

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Kids! What a bunch of lazy.... :rolleyes: Back when I was young, I use to --- Oh my GOSH! I sound like my dad!! :eek:

You know I am not as young as I sound...;)

But still its a good thing people around here consider me as kid...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Damn I thought there was a single click deployement for nested quotes.. this much effort *phew*.

Kudos to those who multiquote :D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

And a much better role model :confused: -- you're not smoking anymore!

I didnt know I was a role model ;)

And btw can someone please tell me how to nest the quotes.

I tried it many times but it just doesnt happen, dont know what I am doing wrong.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

evil fire mage

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

He/she tried that here...

Yeah I know that..but I also pointed out in my post why the code is not working, that was a hint to put the OP on the right track.

The reason it is not working is because you have declared your vResource as
vector vResource<Resource> ;
i.e. a vector of resource objects while you are trying to push a pointer to the resource type ( new returns a pointer which points to the memory which has been allocated by requst ).

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Though I dont know a lot of C++ but here goes nothing...

The reason it is not working is because you have declared your vResource as vector vResource<Resource> ; i.e. a vector of resource objects while you are trying to push a pointer to the resource type ( new returns a pointer which points to the memory which has been allocated by requst ).

Try something like:

int main() 
{
    vector<Resource> vResource; 
    //this line doesn't
    Resource r1( "wheat", 1, 0, 0, "farm" ) ;
    vResource.push_back( r1 ) ; 
    return 0;
}

Hope it helped ,bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I always wonder how you guys come up with such good links you know

Err...I hope you know that he is not exactly a 12 year kid . :mrgreen:

Going into professional software development, hauting the google groups and various forums is what makes a good programmer. (and of course dedication and interest)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

waiting for the

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

he saw that

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

While we are all here voting for the wombats and enjoying ourselves, the OP must be banging his head thinking how come a option he never introduced has got 100% support ;)

.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Create a switch case in the function inputAmount( ) , accept values from the user regarding their option, return the selected value using the return statement.

Store the returned value in a variable in main and then invoke the calculateCommission( ) function using the value returned from the inputAmount( ) function.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

As most of you know, the forum displays a pencil when you have posted in a thread. However, the code snippets section has no identification. I would like it if this feature was available, as I've commented in many snippets and it is hard to remember.

Have already requested for the same thing a long time back..even I have the same problem. Many people post comments on my post and I dont even come to know about it. But looks like Miss Dani is really busy nowadays.

Maybe if you voice my opinions and support me in this thread, Miss Dani will take the issue under consideration.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Wombats..hmm...think I have heard this word somewhere.

Ah its related to Mr. DMR, coz he is the one spreading new about wombats and something about the underbush.

Hehe looks like either there is some bug or one of the moderators have made the poll more interesting. :D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Well it's still available in print, so if somebody suggested to Prentice Hall that they might like to make it available for free on line, I suppose they might think that they had heard of better ideas.

Maybe I should have been more specific, by link I meant recommend. But one thing which is true is it has typos and that I am sure of.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

just posting links and giving more info to orignal poster .

I dont get this point, maybe you wanted me to post link to trial version of AVG ?

Really !! will be watching for you

Err...now that sounds scary.. maybe I better stay in my territory -- its much safer there..:cheesy:

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ohhhhh. That little boy in ~S.O.S~ picture looks like he is in soooo much trouble :mrgreen: 7 girls to 1 boy -- is that what you call a fair contest ?

Oh that... wait till the boys' turn comes. After he has finished his work in the girls' quarter, one of the girls would infiltrate the boys' section and then it would be seven boys and one girl...:twisted:
Yep that's fair :cheesy:

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

As any veteran could tell you, the real "bible" for C programmers was "K & R" (abbreviation), published many years ago by Prentice Hall.

...which has a lot of typo errors.

The link which Mr. Iamthwee pointed out is referred by thousands of people everyday( through Googlegroups, Daniweb or any other forum ). Have you ever seen anyone link to K & R ? But I have seen a lot of posts linking to the above link or some other good pages.

Its not that it is not a good book but the typos there can be fatal to newbies. Once the basics are cleared no harm in referring the book thought there are better online manuals.....

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm... maybe I should even put up a photo here, looks like I am the only one left behind.

Here goes nothing....photo of Kabaddi, a game inherent to India...:D:D:D
[IMG]http://haryanasports.gov.in/photogallery/images/Kabaddi.jpg[/IMG]

:D:D:D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

How do you know?

Because I have been actually through all this....:D

PS: Nice seeing you here Mr. Caperjack, hoping to invade your territory more often :twisted:

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

not posting anything?

:P