![]() |
|
|
|
#1
|
||||
|
||||
|
ok I have a little bit of time on my hands so like the title says, if people are really interested in programming in the language of C++, I will make some tutorials on the language. I will do this if I see that there is a substantial interest in making this tutorial. If you are interested, post in here letting me know that you would like for me to make tutorials on programming in C++
All of the programming I would show you is for your computer on a C++ compiler. I personally use Visual C++ 6.0 Once you can master all of these commands with C++, then you will be that much further with advance programming on the psp. I would start with the basics like expalining variables and data types and showing input and output commands onto your computer screen. Then I would move up to loops such as the for loop, while loop and do-while loop. From there I would go on to operators, switch cases and factorials. From there I would go into the more important commands such as arrays and pointers and math functions where you can calculate volumes and quadratic equations. Then maybe move on to what is used most in psp programming which is functions and classes and structures. Keep in mind that all I have mentioned so far is just the BASIC of C++ programming. If there is a demand for more programming lessons, I will go into the more advance lessons of C++ such as constructors and destructors, pointers, dynamic arrays, pointer casting, dynaimic varibles and templates. Please note that in order to start any programming, You will need a C++ compiler.
__________________
Want to become a PSP Dev the easy way? Check out my tutorial for the PSP here http://www.psp-hacks.com/forums/f141...orial-t152466/ Want to learn how to create your own games on the PSP? Check out my tutorial here http://www.psp-hacks.com/forums/f141...-your-t153653/ Want to learn how to program C++ ? Check out that tutorial here http://www.psp-hacks.com/forums/f124...ram-c-t122337/ |
|
#2
|
|||
|
|||
|
hi every body
i'm totaly good in this languag and i'll try to put some programs fo u guys if intresting and if the psp donkey agreed thank u ghadeer ghazi
__________________
from ghadeer with love |
|
#3
|
|||
|
|||
|
I know this thread is fairly dead, but hopefully someone can take a look at a function I wrote up that I cant seem to get working..
Code:
#include <iostream>
#include <string>
using namespace std;
char gettok(char tokens[], int tok, char delim[])
{
int x[3] = { 0, 0, 0 };
char ret[0];
for (int a = 0; a < strlen(tokens); a++)
{
if (strcmp(tokens[a],delim) == 0) x[1]++;
if (x[1] == tok) x[3] = a, x[2] = x[1];
if (x[3] > 0)
{
if (x[1] > x[2]) break;
strcat(ret,tokens[a]);
}
}
return ret;
}
int main()
{
char input[0], delimiter[1];
int num;
do
{
cout<<"Input a non-spaced string\n";
cin>>input;
cout<<"Input a single char\n";
cin>>delimiter;
cout<<"Input a number\n";
cin>>num;
cout<<gettok(input,num,delimiter)<<endl;
} while (strcmp(input,"0") != 0);
return 0;
}
Code:
Compiler: Default compiler Executing g++.exe... g++.exe "D:\C++ Projects\gettok.cpp" -o "D:\C++ Projects\gettok.exe" -I"D:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"D:\Dev-Cpp\include\c++\3.4.2\backward" -I"D:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"D:\Dev-Cpp\include\c++\3.4.2" -I"D:\Dev-Cpp\include" -L"D:\Dev-Cpp\lib" D:\C++ Projects\gettok.cpp: In function `char gettok(char*, int, char*)': D:\C++ Projects\gettok.cpp:11: error: invalid conversion from `char' to `const char*' D:\C++ Projects\gettok.cpp:11: error: initializing argument 1 of `int strcmp(const char*, const char*)' D:\C++ Projects\gettok.cpp:16: error: invalid conversion from `char' to `const char*' D:\C++ Projects\gettok.cpp:16: error: initializing argument 2 of `char* strcat(char*, const char*)' D:\C++ Projects\gettok.cpp:19: error: invalid conversion from `char*' to `char' D:\C++ Projects\gettok.cpp:8: warning: address of local variable `ret' returned Execution terminated The first parameter should be the char you want to retrieve the given token from, which is the second parameter, and the third param is the token delimiter, or separator. Heres an example of usage: gettok(input,2,delimiter); input = randomly.filled.char delimiter = . So it would return "filled" Thanks. Last edited by NIGathan; 02-21-2009 at 09:24 AM. |
|
#4
|
|||
|
|||
|
Nvm, I got it all fixed using STL strings
Code:
string gettok(string tokens, int tok, string delim)
{
int x = 1, y = 0;
string ret;
for (int a = 0; a < tokens.size(); a++)
{
if (tokens.compare(a,1,delim) == 0) x++;
if (x == tok) y = x;
if (y > 0)
{
if (x > y) break;
ret.append(tokens,a,1);
}
}
if (ret.compare(0,1,delim) == 0) return ret.erase(0,1);
else return ret;
}
|
![]() |
|
|
|||
|
|||
|
|
| Thread Tools | |
| Display Modes | |
|
|