Freaky_Chris 299 Master Poster

Under your post, click "Edit this post"
Then add [*code=c++] before your code and [*/code] after but without the *'s.

[noparse][/noparse] tags are also brilliant!

I agree with ddanbe, you should start simple. Don't just dive into someone elses code and expect to be able to understand it all from the go.

Chris

Freaky_Chris 299 Master Poster

This is a very common question, Salems answer will be perfect for you. But you may want to have a look over some of the topics found here, since they all deal with the same problem and have many explanations of what is going on. It saves us quite a bit of work sometimes if people search what there problem is.
http://www.daniweb.com/search/search.php?q=C%2B%2B+Case+changing

Note: toupper() and tolower() are more reliable that subtract and add '0' to characters because of different character sets!

Chris

Freaky_Chris 299 Master Poster

something like this.

class a{
   public:
      void someFunction(){
             std::cout << "hello";
          }
};
class b{
    public:
       a myClass;
};

int main(void){
    b aClass;
    b.myClass.someFunction();
    std::cin.get();

    return 0;
}

Or is inheritance what you are after?

Chris

Freaky_Chris 299 Master Poster

What is the difference between hkeletal animation and procedural animation? I get different answers each time

Skeletal animation is about manipulating bones attached to different polygon groups. This makes animation easy and quick, however it is also some what more limiting that procedural which runs in real time. Procedural can apply different rules and information to different objects so that they all have the desired effect without the action having to be known before. IE a character walking is perhaps done with bones. But rag-doll physics, is most definitely done using procedural animation since you have no way of knowing where the character is going to be when he dies, thus you cannot program the bones to over correctly before hand. However procedural program has the ability to apply physics and correctly animate the body no matter where it is located at the given moment.

Chris

Freaky_Chris 299 Master Poster

Have you made sure that your Window is actually in full screen, with borders etc removed? My guess is you are making your drawing space 3D but not the actual window.

You window should have properties that resemble the following.

hWnd = CreateWindowEx(NULL, L"WindowClass", L"Basic Window",
                          WS_EX_TOPMOST | WS_POPUP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
                          NULL, NULL, hInstance, NULL);

WS_EX_TOPMOST, making sure it is on top. Above start bar etc. WS_POPUP removes the borders etc, SCREEN WIDTH & SCREEN_HEIGHT are self explanatory. basically the resolution.

Chris

Freaky_Chris 299 Master Poster

What exactly do you mean, 'the image'. It could be a whole host of reasons.

Chris

Freaky_Chris 299 Master Poster

Just to pop in as a reality check.
Simple user input guessing game and such are simple to achieve and C++ perfectly capable. If however you are wanting to look into something not text based and a using graphics....more like a modern game for example Call of Duty. Then you have alot of work to do.

Before you can even start thinking about making a game you need to spend a good few years mastering C++ and knowing it inside out!

Once you have reached this stage then you can start looking into graphics library's such as OpenGL and DirectX. Which will enable you to create games with basically no limits. The best language to develop in is going to be C++ without a doubt.

3D max and other 3D modelling software such as blender and Maya, are sides which you (ideally: pretty much a must) can use to create 3D models to be loaded into your game.

For example DirectX can import .X files containing mesh's and texture rendering details about and object as well as many other things. Belder for example has a python script attached to it to allow you to export these .X files.

Summary:
You will NOT create a 'modern' game from the off, you need a good number of years behind you, and a very good understanding of the language and graphics API you intend to use.
don't assume that someone can teach you anything about …

Freaky_Chris 299 Master Poster

When reading files in binary you must specify whether you are opening it for in or out operations or both using fstream videoFile("myVideo.m2v", ios::in | ios::out | ios::binary); that would open the file for input and output in binary mode.

you use single quites for char's also is by zero'ing a byte you mean a null terminated char then it should be '\0'

Chris

Freaky_Chris 299 Master Poster

I think his answers your question...although i'm not entirerly sure :D

#include <iostream>
#include <vector>

using namespace std;

template <class T>
class test{
    public:
        test(T[]);
        void print();
    private:
        vector<T> v;
};

int main(void){
    char myArray[] = {'a', 'b', 'f'};

    test<char> myClass(myArray);
    myClass.print();

    cin.get();
    return 0;
}

template <class T>
test<T>::test(T example[]){
    for(int i = 0; i < (sizeof(example)/sizeof(*example))-1; i++){
        v.push_back(example[i]);
    }
}

template <class T>
void test<T>::print(){
    for(int i = 0; i < v.size(); i++){
        cout << "example " << i << ": " << v[i] << endl;
    }
}

Since you never posted what the problematic code was nor the error's you were getting.

Chris

Freaky_Chris 299 Master Poster

I think your missing the point. YOU haven't done ANY work....why the hell should we!

Chris

Salem commented: Why indeed! +25
Freaky_Chris 299 Master Poster

You can't even be bothered to re-write the question!!!!
or copy and paste!!

This is new levels lazyness, i actually cannot believe it!

Chris

Freaky_Chris 299 Master Poster

Thanks for the very nice post! Makes my life so much simpler.

The solution, you need to clear your stringstream before throwing the next string at it. Using ss.clear(); . Then in your loop that prints the results out, you need to change the way in which you access your vector elements in v2. Since you will always use 0..4, whereas you want 0..4, 5..9 , and so on. Only two minor changes. Here they are:

#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;

int main() {
    string s, line, segments;
    vector<string> v, v2;
    ifstream in("test.txt");
    stringstream ss;
    string data [4][5];

    // read in each line
    while(getline(in,line)) {
        v.push_back(line);
    }

    cout << v[0] << endl; // Printing out these
    cout << v[1] << endl; // gives the expected
    cout << v[2] << endl; // results.
    cout << v[3] << endl;

    // Try and sort elements of each line
    // into a 2D array:
    for (int i=0; i < 4; i++) {
        ss << v[i]; 
        while (getline(ss,segments,'\t')) {
            v2.push_back(segments);
        }
        for (int j=0; j < 5; j++) {
            data[i][j] = v2[j+(i*4)]; // updated from 'j' to 'j+(i*4)'
            cout << data[i][j];
        }
        ss.clear(); // added to lcear ss buffer.
    }
    cin.get();
    return 0;
}

Also please be sure to do some error checking whenit comes to opening files.

Thanks,
Chris

Freaky_Chris 299 Master Poster

if your developing for windows and don't wanna go download some extra libraries and things then you can use the Win32 API. It give's you all the stuff you need to do this, just if your a beginner it might be a little complex.

Chris

Freaky_Chris 299 Master Poster

The first part is correct.
The second part well shouldn't really be a problem

D3DXCreateTextureFromFile()

Allows the use of png files...

Perhaps i mis-understood your question?

Chris

Freaky_Chris 299 Master Poster

Don't see why it doesn't work, but long story short!

Get an IDE that isn't frozen. Like Code::Block or VC++

Chris :D

Freaky_Chris 299 Master Poster

As far as i am aware the \b doesn't work for linefeeds...

Chris

Freaky_Chris 299 Master Poster

:( Looks like it will be easier to invent another UI..

P.S. Just in case someone will be willing to suggest some particular OS specific solution: I am using Mac

Thats why a GUI was invented....i could of gave you a windows specific solution easy enough...and probably found a linux solution but mac just makes it some what harder since i don't see as many people wanting to do it on mac. You would have to find a library that is compatiable with mac....im not sure if pdcurses and curses libraries are compatably with it. I guess it quite possible since if i am correct they are based around the same technology.

Chris

Freaky_Chris 299 Master Poster

I'm guessing that the only way you could do this would be to use the windows api and or pdcurses library and move the cursor around as you please...which is not going to be as simple as you are hoping. I guessed if you are using managed C++ then it could be a bit easy as you will be able to use gotoxy(), but either way it isn't portable.

Chris

Freaky_Chris 299 Master Poster

in your if statements you are assign the value of 0 and 1 to your variable a, thus it will always evaluate true. I'm guessing you should be using ==. Also since you have an unanitialized variable a, using the == would just be dangerous....

Chris

Freaky_Chris 299 Master Poster

May be you can use some container in STL, such as vector.

Perhaps you should pay attenyion to the posts....the idea looks to be that he isn't allowed to hence why it was suggested he implemented his OWN version of a vector

Chris

Freaky_Chris 299 Master Poster

Please use code tags. These a thread related to them infact there all over the place!
Chris

mrboolf commented: Yeah no need to even bother opening the announcement - it's written right on top of the forum :-) +2
Freaky_Chris 299 Master Poster

i Should note it should be 0..1..2 on my array in the post very accidental mistake sorry

Chris

Freaky_Chris 299 Master Poster

cout.flush ????

This is a discussion about flush the INPUT buffer....so this is a completely pointless post, before making a suggestion at least make it a viable suggestion

Chris

Freaky_Chris 299 Master Poster

oh the day of the week, my bad. Either way i'm sure you could have adapted the information given by that webpage it's not too complex.

#include <iostream>
#include <ctime>
#include <string>

using namespace std;

int main (void){
  time_t rawtime;
  struct tm * timeinfo;

  time ( &rawtime );
  timeinfo = localtime ( &rawtime );
  string day(asctime (timeinfo));
  cout << "Date: " << day.substr(0, day.find_first_of(" "));
  
  cin.get();
  return 0;
}

Chris

Freaky_Chris 299 Master Poster

Your question is a bit bizzare. What do you mean by week name?

But perhaps this would be helpful
http://www.cplusplus.com/reference/clibrary/ctime/localtime.html

Chris

Freaky_Chris 299 Master Poster

Visual C++ Express also has some nice stuff to it...so it's worth looking at both that and Code::Blocks and seeing which you prefer to work with....also VC++ allows you to used managed C++.

P.S If the you have your solution please mark the thread as solved.

Chris

Freaky_Chris 299 Master Poster

Also, if you are inputing straingth from the console, you may try getchar(), the one i mentioned above is for reading from streams. :IDEA:

There's and edit button for a reason :P

@OP
You may think it looks a bit confusing but it's really not that complex

Chris

Freaky_Chris 299 Master Poster

I would read the input in as a string, then loop through each charcter in the string and check whats its value is using some boolean values to make note of things.

cctype header has some nice functions such as isalpha and is digit that will allow you to accomplish this task reasonable simply.

here is a simple example of what i mean
[edit]
[snipped reason= multiple posting, even after solution provided]I'm un willing to provide a code example to such a rude poster[/snipped]

DO NOT MULTIPLE POST!
[/edit]

Chris

Freaky_Chris 299 Master Poster
Freaky_Chris 299 Master Poster

Read the bulletin about code tags too.

Chris

Freaky_Chris 299 Master Poster

I guess thread spawning would class as recursion too?

Embed Python code into your C++ and do the following.

print "Hello World\n"*100

:D

Chris

Freaky_Chris 299 Master Poster

thats because of this line
int answer = atoi(av[1]);

av[1] will not exist, unless ac >= 2

Chris

Freaky_Chris 299 Master Poster

For DevCpp i'm guessing the easiest fix for you would just be to create a new project and put all of your files into that project and then compile it.

Chris

Freaky_Chris 299 Master Poster
if (argc=='0'){

Do you realise what you are doing here?
argc is a number representing the number of command line arguments passed to your program. '0' is equivelant to 48, so you say if 48 command line arguments are passed then do X. I expect that is now what you ment to do.

theoretically the following should work

if(argc==0){
  //display error message or whatever cause no arguments passed!
}

However we then get into a whidely debated topic about the minimal acceptable number of commandline arguments.

Many operationg system pass the file name (or executable path) tothe application by default making the default length equal to 1 and then additional command line arguments added by the users will increase from there.

However it is not written in C++ ANSI Standards that the first commandline argument passed is equal to the filename/exectuable path. Thu making this much more difficult than you imagine.

However it is a reasonably safe assumption to assume that the first argument is the filename/executable path. Thus you can use the following.

if(argc==1){
// no custom arguments add do something
}else{
// argv[1] is equal to the first argument the user passed!
}

Hope all this helps.
(i'm probably gonna get grilled by some experts now :D)

Chris

Freaky_Chris 299 Master Poster

simplest method is to do something like this

cin.ignore ( 80, '\n' );
cin.get()

The reason cin.get() appear to be skipped is that it reads one character from the input stream.

After calling cin >> you find that at least the '\n' character is left in the inputstream. Thus cin.get() will read this as requested which then leaves you a clean inputstream. In this case calling cin.get() again solves the problem.

Chris

Freaky_Chris 299 Master Poster

That's nice. Have fun.

That's the no-shit way of saying, read the posting rules before you make a post. Also it helps to ask a question and present us with some problematic code or logical issue.

I'm sure you can find the posting guidlines thread. Also learn to use code tags before you make that mis-take :D

Chris

Freaky_Chris 299 Master Poster

system("pause");
is not really adviseable.
cin.get() is doing it's job just fine... unfortunately it's all a little complex. There is a sticky at the top of the C++ forum Called "How do i flush the input buffer"...it may all seem a little confusing but never the less it's worth the read.

One quick solution is cin.get(); cin.get(); just call it twice you can also go down the line of cin.ignore() and many other methods all discused in that the thread>

Chris

Freaky_Chris 299 Master Poster

and use cin.get();

to pause so you can see the result

use return 0;

Chris

Freaky_Chris 299 Master Poster

Try initialising the array to 0?

Freaky_Chris 299 Master Poster
for(counternumbers = 1; counternumbers <= 19; counternumbers++){
    cout << digit[counternumbers] << ", ";
}
cout << digit[counternumbers];

First things first, Arrays are 0 index'ed. This means the first element within the array is 0 not 1. That is your first mistake. Number 2, you have an array of size 19 thus that is 0..18. using the <= operator you print number 1..19 and then you go on and print another character outside of the loop. Since the memory at point digit[19] and upwards isn't controlled by you, you are accessing random data, thus printing out what is junk. You should always be careful with thinks like this.

Change it to

for(counternumbers = 0; counternumbers < 19; counternumbers++){
    cout << digit[counternumbers] << ", ";
}

You may have other problems i have meerly address that one!

Chris

Freaky_Chris 299 Master Poster

Long story short, because standards have changed since the days of Turbo C++ and also the compiler also does some work automatically for you sometimes.

(btw if the thread is solved don't forget to mark it as solved)

Chris

Freaky_Chris 299 Master Poster

Then you would of tried and then realized it wasn't possible or failed trying and asked for help and someone would of helped you out. Either way it would of been a learning experience even if it wasn't possible.

Chris

Freaky_Chris 299 Master Poster
Freaky_Chris 299 Master Poster

Just to note, it was not all about efficiency more demonstrating something, it also left him values to work with and didn't provide the actually solution to his problem meerly demonstrated a method in which he could adapt to get the solution he was after.

[edit] if you want a more hacky solution

#include <iostream>
#include <string>
#include <cctype>

int main(void){
    std::string input;
    int total = 0;
    getline(std::cin, input);
    for(int i = 0; i < input.length(); i++) (isalpha(input[i]) ? total+= (toupper(input[i])-64) : total+=0);
    std::cout << total;
    return 0;
}

Chris

Freaky_Chris 299 Master Poster

You could call,

myFile.seekg(0, ios::beg);

P.S. If your problem is solved please mark the thread as solved

Thanks,
Chris

Freaky_Chris 299 Master Poster
#include <iostream>
#include <string>
#include <cctype>
#include <vector>

using namespace std;

int main(void){
    string input;
    vector<char> v;
    while(1){
        cout << "Enter a string:\n>>";
        getline(cin, input);
        for(int i = 0; i < input.length(); i++){
            if(isalpha(input[i]) != 0){
                cout << input[i];
                v.push_back(input[i]);
            }
        }
        cout << "\nNumerical Value: ";
        for(int i = 0; i < v.size(); i++){
            cout << toupper(v.at(i))-64;
        }
        v.clear();
        cout << endl;
    }
    return 0;
}

Hope that makes sense

Chris

Freaky_Chris 299 Master Poster

Dear Ninwa
Thanks for your reply but still I can not write the whole coding structure which I needed.It doesn't make any sense to me.
I shoud be able to compile and run it in order to see how it works.
I would be very happy if you could write the codes from A to Z with detailed explanations.
Regards
ADAM

Not gonna happen this is not your homework solution lounge.
It's a guidance forum!

Chris

Salem commented: Absolutely +25
Freaky_Chris 299 Master Poster

isalpha()

Loop throught the input string, copy any alpha characters across to a new string, just ignore others

Chris

Freaky_Chris 299 Master Poster

@singhraghav
1) Don't Hijack threads - Start your own (we much much prefer it)
2) After 13 posts you are expect to now how to use code tags
(read this)

Follow that advise and you will get some help.

Thanks,
Chris

Freaky_Chris 299 Master Poster

[code=cplusplus]//your code here [/code]

Chris