Search found 156 matches

by zodiac976
Wed Jul 08, 2009 11:41 am
Forum: Programming Discussion
Topic: [Solved] Question on data types
Replies: 6
Views: 600

Re: [Solved] Question on data types

programmerinprogress wrote:
zodiac976 wrote:
Ginto8 wrote:scanf FTW!

Just putting that out there
Isn't that for C and not C++?
but you are free to use it, I tend to use strlen() instead of string.length(), because it's just plain easier :lol:
Yep, but I am so used to strings and I always use .length() :lol:.
by zodiac976
Wed Jul 08, 2009 11:40 am
Forum: Programming Discussion
Topic: C-strings and strings
Replies: 4
Views: 471

Re: C-strings and strings

Netwatcher wrote:If you're using MFC...
I am unfamiliar with "MFC". Is that bad? :(
by zodiac976
Wed Jul 08, 2009 11:18 am
Forum: Programming Discussion
Topic: C-strings and strings
Replies: 4
Views: 471

C-strings and strings

I tend to use strings all the time and rarely use C- strings, just like references and pointers I used references a ton more than pointers but now I am using pointers and references about the same now maybe more with pointers :lol:. Can anyone give me an idea or example when it is more appropriate t...
by zodiac976
Wed Jul 08, 2009 4:51 am
Forum: Programming Discussion
Topic: std::string-to-int converter
Replies: 36
Views: 3414

Re: std::string-to-int converter

Lucky, I spent most of my teen years doing much of nothing and
it took me about 14+ years to come across something I really
enjoy which is programming/game programming ;P. I got lucky
though I just came across a C++ class in college and that's how I
got hooked. I am way behind everyone though :(.
by zodiac976
Wed Jul 08, 2009 4:45 am
Forum: Programming Discussion
Topic: [Solved] Question on data types
Replies: 6
Views: 600

Re: [Solved] Question on data types

Ginto8 wrote:scanf FTW!

Just putting that out there
Isn't that for C and not C++?
by zodiac976
Wed Jul 08, 2009 4:44 am
Forum: Programming Discussion
Topic: [Solved] Pause Function
Replies: 31
Views: 2079

Re: [Solved] Pause Function

ok... I'm surprised no one else has thought of this: #include <conio.h> int main() { ... getch(); ... } Note that it only works on windows, but it is exactly the kind of thing you're looking for zodiac Actually I did post that but you can't use getch() like that the compiler will say to use _getch(...
by zodiac976
Wed Jul 08, 2009 12:44 am
Forum: Programming Discussion
Topic: Regards
Replies: 4
Views: 452

Re: Regards

Character*? I'm hoping you don't mean a substitution for char, because dynamic arrays of chars are about the most useful things in C++. example of a possible use for them (a static array would probably be more appropriate for certain parts): char* myCStyleStr = calloc((strlen("Hello World!&quo...
by zodiac976
Tue Jul 07, 2009 8:20 am
Forum: Programming Discussion
Topic: std::string-to-int converter
Replies: 36
Views: 3414

Re: std::string-to-int converter

I prefer to use stringstream for converting than atoi, etc.

#include <sstream>

strings to whatever:
stringstream input(string variable);
input >> variable;

whatever to strings:
stringstream output;
output << variable;
output = variable.str();
by zodiac976
Tue Jul 07, 2009 8:17 am
Forum: Programming Discussion
Topic: Looking for advice on programming
Replies: 20
Views: 3091

Re: Looking for advice on programming

I got to looking at my ATM simulator(new version) again
and it is funny how you make something, look at it after
it is done then you realize why in the world did I do it this
way or why didn't I do this instead :lol:.
by zodiac976
Tue Jul 07, 2009 8:06 am
Forum: Programming Discussion
Topic: [Solved] File Streaming Question
Replies: 11
Views: 999

Re: File Streaming Question

oh yeah, duh, it wouldnt take in any data, because the stream doesn't pick up any of the data, you could just file >> temp on the default part and then break afterwards, it would probably look more consistent, also, you wouldn't have to rely on everything being on a seprate line, which would be a p...
by zodiac976
Tue Jul 07, 2009 8:00 am
Forum: Programming Discussion
Topic: [Solved] File Streaming Question
Replies: 11
Views: 999

Re: File Streaming Question

You are lucky that your code works. You need a break for each case. wow, i'm sloppy today, of course you do! in this case, because 'i' can only be one value which doesn't get altered until after each iteration, a break statement is not essential, but really, you need to put one in there, just incas...
by zodiac976
Tue Jul 07, 2009 7:59 am
Forum: Programming Discussion
Topic: [Solved] File Streaming Question
Replies: 11
Views: 999

Re: File Streaming Question

K-Bal wrote:You are lucky that your code works. You need a break for each case.
I usually do breaks after each case but the code still
works either way.
by zodiac976
Tue Jul 07, 2009 6:32 am
Forum: Programming Discussion
Topic: [Solved] File Streaming Question
Replies: 11
Views: 999

Re: File Streaming Question

Actually that did work but I had to change a few things to get it to work, here is the working code :mrgreen: weapon.txt knife 1 2 shortsword 2 5 longsword 5 8 main.cpp #include <iostream> #include <fstream> #include <string> using namespace std; int main() { string garbage, weapName; int minDamage,...
by zodiac976
Tue Jul 07, 2009 6:17 am
Forum: Programming Discussion
Topic: [Solved] File Streaming Question
Replies: 11
Views: 999

Re: File Streaming Question

Thanks, I will test it out and see if it does work. I should
have thought of something like that myself....my brain is
rusty or something :lol:.
by zodiac976
Tue Jul 07, 2009 4:26 am
Forum: Programming Discussion
Topic: [Solved] File Streaming Question
Replies: 11
Views: 999

[Solved] File Streaming Question

I am looking for a quick way to get data from a file. Take this file for instance: weapon.txt knife 1 2 shortsword 2 5 longsword 5 8(end of file) Normally when I want to grab data from the file I do this: #include <iostream> #include <fstream> using namespace std; int main() { string temp; //Just a ...