Find fields & stores near you!
Find fields and stores
Zipcode
PbNation News
PbNation News
Community Focus
Community Focus

Reply
 
Thread Tools
Old 05-06-2012, 06:15 PM #43
Blazestorm2
I like me
 
Join Date: Sep 2006
Location: Singapore
Pre-process is the simplest. Not the most efficient, but that's probably not important to your teacher.

I'd say just have a 2nd string, and just copy character by character those that pass your requirements. Then use the 2nd string for actually checking.
Blazestorm2 is offline   Reply With Quote
Old Sponsored Links Remove Advertisement
Advertisement
Old 05-06-2012, 06:18 PM #44
paintballking72
Yummy! :-)
 
paintballking72's Avatar
 
Join Date: Nov 2006
Location: Midwest(Ks) ((316))
paintballking72 owns a Planet Eclipse Ego
What is the simplest way to do that?
paintballking72 is online now   Reply With Quote
Old 05-06-2012, 06:35 PM #45
Blazestorm2
I like me
 
Join Date: Sep 2006
Location: Singapore
Just try some stuff, that's basically the core of programming. Problem solving.
Blazestorm2 is offline   Reply With Quote
Old 05-07-2012, 12:36 AM #46
paintballking72
Yummy! :-)
 
paintballking72's Avatar
 
Join Date: Nov 2006
Location: Midwest(Ks) ((316))
paintballking72 owns a Planet Eclipse Ego
I figured out a what to do it. I basically just make a temporary array, called tempWord[100]. I ask the user for a word and populate tempWord with their input.

I then check the array for characters not equal to '&', '#', ' ', etc. I then add all valid letters or numbers to my word[100] array.

Then I check that to see if it is a palindrome. The only problem is, when I add the numbers and letters into word, it adds a bunch of other non-sense to the other indexes in word. So then it always comes out to be an invalid palindrome. Any idea why it would do that?
paintballking72 is online now   Reply With Quote
Old 05-07-2012, 01:29 AM #47
Blazestorm2
I like me
 
Join Date: Sep 2006
Location: Singapore
Well when you're adding them to your 2nd array, you're using the same index for both arrays. You would need a 2nd index when you're adding, only incrementing it when you add a new value.

Also need to make sure your strings are null-terminated.
Blazestorm2 is offline   Reply With Quote
Old 05-21-2012, 10:19 AM #48
OhIoCoNtRActKilLa
 
 
Join Date: Jun 2007
Any PHP developers that can chime in?

http://stackoverflow.com/questions/1...87435#10687435
OhIoCoNtRActKilLa is offline   Reply With Quote
Old 07-02-2012, 01:31 AM #49
DrewDodson89
 
 
DrewDodson89's Avatar
 
Join Date: Mar 2005
Location: San Diego
Annual Supporting Member
How can I find out the currently logged on user then create a text file on the desktop of that user? I have been researching for hours, trying different code and I am still unable to do this.

I in using C++

Thanks,
Drew
__________________

Kiwi!
ಠ_ಠ
DrewDodson89 is offline   Reply With Quote
Old 07-02-2012, 06:58 AM #50
Blazestorm2
I like me
 
Join Date: Sep 2006
Location: Singapore
You would need some OS specific functions in that case. There isn't a C++ standard way of finding out what's the path of the desktop.
Blazestorm2 is offline   Reply With Quote
Old 07-02-2012, 12:38 PM #51
DrewDodson89
 
 
DrewDodson89's Avatar
 
Join Date: Mar 2005
Location: San Diego
Annual Supporting Member
Quote:
Originally Posted by Blazestorm2 View Post
You would need some OS specific functions in that case. There isn't a C++ standard way of finding out what's the path of the desktop.
There is the function
Code:
SHGetSpecialFolderPath
I am working with. So far I have...

Code:
int main() { using namespace std; CHAR strPath[ MAX_PATH ]; SHGetSpecialFolderPathA( 0, strPath, // String buffer. CSIDL_DESKTOPDIRECTORY, // CSLID of folder FALSE ); cout << strPath << endl; ofstream myfile; myfile.open (string(strPath) + "\\text.txt"); cout << "Starting File copy to Desktop." << endl; }
But it yields compiling errors for the myfile.open line about the string and concatenation.

Code:
c:\users\drew\dropbox\1\prep\prep\prep.cpp(27): error C2784: 'std::_String_iterator<_Mystr> std::operator +(_String_iterator<_Mystr>::difference_type,std::_String_iterator<_Mystr>)' : could not deduce template argument for 'std::_String_iterator<_Mystr>' from 'const char [10]' c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(418) : see declaration of 'std::operator +' c:\users\drew\dropbox\1\prep\prep\prep.cpp(27): error C2784: 'std::_String_const_iterator<_Mystr> std::operator +(_String_const_iterator<_Mystr>::difference_type,std::_String_const_iterator<_Mystr>)' : could not deduce template argument for 'std::_String_const_iterator<_Mystr>' from 'const char [10]' c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstring(286) : see declaration of 'std::operator +' c:\users\drew\dropbox\1\prep\prep\prep.cpp(27): error C2784: 'std::move_iterator<_RanIt> std::operator +(_Diff,const std::move_iterator<_RanIt> &)' : could not deduce template argument for 'const std::move_iterator<_RanIt> &' from 'const char [10]' c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1938) : see declaration of 'std::operator +' c:\users\drew\dropbox\1\prep\prep\prep.cpp(27): error C2784: 'std::_Array_iterator<_Ty,_Size> std::operator +(_Array_iterator<_Ty,_Size>::difference_type,std::_Array_iterator<_Ty,_Size>)' : could not deduce template argument for 'std::_Array_iterator<_Ty,_Size>' from 'const char [10]' c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1792) : see declaration of 'std::operator +' c:\users\drew\dropbox\1\prep\prep\prep.cpp(27): error C2784: 'std::_Array_const_iterator<_Ty,_Size> std::operator +(_Array_const_iterator<_Ty,_Size>::difference_type,std::_Array_const_iterator<_Ty,_Size>)' : could not deduce template argument for 'std::_Array_const_iterator<_Ty,_Size>' from 'const char [10]' c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1653) : see declaration of 'std::operator +' c:\users\drew\dropbox\1\prep\prep\prep.cpp(27): error C2784: 'std::reverse_iterator<_RanIt> std::operator +(_Diff,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const char [10]' c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1217) : see declaration of 'std::operator +' c:\users\drew\dropbox\1\prep\prep\prep.cpp(27): error C2784: 'std::_Revranit<_RanIt,_Base> std::operator +(_Diff,const std::_Revranit<_RanIt,_Base> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const char [10]' c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1029) : see declaration of 'std::operator +' c:\users\drew\dropbox\1\prep\prep\prep.cpp(27): error C2676: binary '+' : 'std::basic_string<_Elem,_Traits,_Alloc>' does not define this operator or a conversion to a type acceptable to the predefined operator 1> with 1> [ 1> _Elem=char, 1> _Traits=std::char_traits<char>, 1> _Alloc=std::allocator<char> 1> ]
__________________

Kiwi!
ಠ_ಠ
DrewDodson89 is offline   Reply With Quote
Old 07-02-2012, 11:26 PM #52
Blazestorm2
I like me
 
Join Date: Sep 2006
Location: Singapore
Right, because there is no defined operator+ for string and char const*... if it was two string's then you'd be fine..

This works on my machine, VS2010 with a ASCII for character set, not Unicode.

MSDN for the SHGetFolderPath

Code:
#include <fstream> #include <Shlobj.h> int main ( void ) { char desktop_path_buffer[ MAX_PATH ]; SHGetFolderPath( NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, desktop_path_buffer ); std::string desktop_path( desktop_path_buffer ); desktop_path += "\\test.txt"; std::ofstream myfile( desktop_path ); if( myfile.is_open() ) { myfile << "Success!" << std::endl; myfile.close(); } return 0; }

Last edited by Blazestorm2 : 07-02-2012 at 11:29 PM.
Blazestorm2 is offline   Reply With Quote
Old 07-03-2012, 12:13 AM #53
Jagov Fapsky (Banned)
=^_^=
 
Join Date: Nov 2011
Jagov Fapsky owns a Planet Eclipse Geo
Jagov Fapsky has achieved Level 1 in PbNation Pursuit
Jagov Fapsky is offline   Reply With Quote
Old 07-20-2012, 03:30 AM #54
DrewDodson89
 
 
DrewDodson89's Avatar
 
Join Date: Mar 2005
Location: San Diego
Annual Supporting Member
Blaze, is it possible to add a user defined variable to a set item?

Code:
system("xcopy Files" + desktop_path + "Files /e");
__________________

Kiwi!
ಠ_ಠ
DrewDodson89 is offline   Reply With Quote
Old 07-20-2012, 01:26 PM #55
Blazestorm2
I like me
 
Join Date: Sep 2006
Location: Singapore
Set item?

If you're using C++, you can use stringstreams which let you build up more complex strings using operator<<. It's basically like std::cout, except you can grab the std::string that would represent the output you put into it.

Code:
#include <sstream> #include <string> int main( void ) { std::stringstream ss; std::string files ("*.txt"); std::string desktop_path(C:\\Users\\Joe\\Desktop"); float percentage = 0.95f; int rand_int = 12; ss << "xcopy" << percentage << rand_int << desktop_path << files << "/e"; // stringstream can be converted into std::string with .str(), then // you convert the temporary std::string into a char const* with c_str() system( ss.str().c_str() ); return 0; }
Or are you talking about like environment variables? I can kinda see what you're trying to do. I haven't used "system" in a long time, I'm assuming it takes your string and tries to pass it to the command-line to execute.

Last edited by Blazestorm2 : 07-20-2012 at 01:29 PM.
Blazestorm2 is offline   Reply With Quote
Old 07-20-2012, 10:18 PM #56
DrewDodson89
 
 
DrewDodson89's Avatar
 
Join Date: Mar 2005
Location: San Diego
Annual Supporting Member
Quote:
Originally Posted by Blazestorm2 View Post
Set item?

If you're using C++, you can use stringstreams which let you build up more complex strings using operator<<. It's basically like std::cout, except you can grab the std::string that would represent the output you put into it.

Code:
#include <sstream> #include <string> int main( void ) { std::stringstream ss; std::string files ("*.txt"); std::string desktop_path(C:\\Users\\Joe\\Desktop"); float percentage = 0.95f; int rand_int = 12; ss << "xcopy" << percentage << rand_int << desktop_path << files << "/e"; // stringstream can be converted into std::string with .str(), then // you convert the temporary std::string into a char const* with c_str() system( ss.str().c_str() ); return 0; }
Or are you talking about like environment variables? I can kinda see what you're trying to do. I haven't used "system" in a long time, I'm assuming it takes your string and tries to pass it to the command-line to execute.
Nailed it with the last comment. I am trying to take a command and throw my variable into from the CSIDL_Desktop from earlier.
__________________

Kiwi!
ಠ_ಠ
DrewDodson89 is offline   Reply With Quote
Old 07-21-2012, 07:21 AM #57
Blazestorm2
I like me
 
Join Date: Sep 2006
Location: Singapore
You'd have to do some searching on MSDN / Stackoverflow. I haven't dealt with a lot of Windows specific stuff.

For simple stuff like that I've resorted to batch files / starting to learn Powershell (basically Window's Bash). Batch files have access to environment variables pretty easily and can execute a lot of basic commands like that.
Blazestorm2 is offline   Reply With Quote
Old 07-21-2012, 12:05 PM #58
DrewDodson89
 
 
DrewDodson89's Avatar
 
Join Date: Mar 2005
Location: San Diego
Annual Supporting Member
Quote:
Originally Posted by Blazestorm2 View Post
You'd have to do some searching on MSDN / Stackoverflow. I haven't dealt with a lot of Windows specific stuff.

For simple stuff like that I've resorted to batch files / starting to learn Powershell (basically Window's Bash). Batch files have access to environment variables pretty easily and can execute a lot of basic commands like that.
I have created a few Batch files but wanted to try out with C++. I have never even looked at Powershell. Maybe, I will have a look at that and see what the differences.

Thanks!
__________________

Kiwi!
ಠ_ಠ
DrewDodson89 is offline   Reply With Quote
Old 09-16-2012, 02:20 PM #59
spinny2559
just missed 2k4
 
spinny2559's Avatar
 
Join Date: Jan 2005
spinny2559 is a Supporting Member
Any .NET developers here?!
If so, feel free to say hi! I'll say hi back...
__________________

98 Custom Low Pressure Kit parts available, contact me!

TONS of solenoids and solenoid parts F/S/T!!

spinny2559 is offline   Reply With Quote
Old 09-23-2012, 10:37 PM #60
pflfranco
It's Josh
 
pflfranco's Avatar
 
Join Date: Jan 2010
Location: Chicago, IL
pflfranco is playing at Living Legends VI
pflfranco supports Team VICIOUS
pflfranco supports Team VICIOUS
pflfranco posts videos on PbNation
pflfranco is one of the top 1000 posters on PbNation
pflfranco is Legendary
pflfranco supports DLX Technology
Epic thread.. I am in school for IT networking. The more and more time I spend around programming makes me want to switch my major. Any opinions?
pflfranco is offline   Reply With Quote
Old 09-24-2012, 12:51 AM #61
spinny2559
just missed 2k4
 
spinny2559's Avatar
 
Join Date: Jan 2005
spinny2559 is a Supporting Member
Quote:
Originally Posted by pflfranco View Post
Epic thread.. I am in school for IT networking. The more and more time I spend around programming makes me want to switch my major. Any opinions?
What is it about programming that you like? And any specific kind of programming?
What do YOU like to do?
__________________

98 Custom Low Pressure Kit parts available, contact me!

TONS of solenoids and solenoid parts F/S/T!!

spinny2559 is offline   Reply With Quote
Old 09-24-2012, 09:46 AM #62
Mustang7302
has been here too long
 
Mustang7302's Avatar
 
Join Date: Sep 2001
Location: Houston, TX
Mustang7302 is a founding member
 has been a member for 10 years
Mustang7302 has achieved Level 3 in PbNation Pursuit
I work with VB, VBA, and C# regularly; often with ADODB objects for SQL and Oracle data input/output.
__________________
Cars, Technology, and Stogies ... All the fine things in life.

"Originally posted by Volucris: Computers are tools. Man is separated by how well he chooses his tool."

"Originally posted by Rebeltilldeath3: We went from Allan Sheppard, Gus Grissom, Neil Armstrong, and Buzz Aldrin to Charlie Sheen, Lindsay Lohan, and Snooki."
Mustang7302 is offline   Reply With Quote
Old 09-24-2012, 03:13 PM #63
pflfranco
It's Josh
 
pflfranco's Avatar
 
Join Date: Jan 2010
Location: Chicago, IL
pflfranco is playing at Living Legends VI
pflfranco supports Team VICIOUS
pflfranco supports Team VICIOUS
pflfranco posts videos on PbNation
pflfranco is one of the top 1000 posters on PbNation
pflfranco is Legendary
pflfranco supports DLX Technology
Quote:
Originally Posted by spinny2559 View Post
What is it about programming that you like? And any specific kind of programming?
What do YOU like to do?
Honestly I know the bare minimums for both subjects. Just getting into my major in college. So I am not sure which I would like to do. From what I have read and heard, programming is much harder. Which is fine with me. I would rather have harder work than sit around playing WoW until a problem comes up lol. I know it's a noob question, I apologize.
pflfranco is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
Forum Jump