|
greetings and except my humbleness in asking you for your help, my general day to day doesn't involve a lot of actual programming, so when this came up i have been beating my head over it and finally succumbed to he kindness of strangers to help get it done. this is, in essence a C++ issue, as most of the string functions available to C++ are available to me, but it is built into an interface engine, so it is really base level (stuck to the basics, loops, ifs, etc). enough babble - here is what i need to do.
I am fed the following string:
720^JONES, A ANTHONY~^JONES, J JOHN~88^JOHSON, L
which is DRNUMBER^LASTNAME, MIDDLE INITIAL FIRSTNAME~NEXT DR~ and so on.
I am tasked with stripping out the occurances of dr.s without numbers, so any case without a number before the carat and then passing the string along with the others intact.
Any help would greatly appreciated!
Jason
|
|
|
|
|
You could use a strtok() function (or CStringT::Tokenize() if you're using CString)
to move from entry to entry ('~' is the delimeter).
For each string, compare the first character to '^' and/or check if it's numeric.
If it's a valid string, output it, else continue to next string.
Also, C++ questions that aren't related to Managed C++ should be posted on
the Visual C++/MFC board.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
On the C++/CLI when I was checking this code I got this message (a compiler error, C1001)
generic<class T>
T General::Show(T value)
{
T result;
Console::WriteLine(value);
result=value+2;
return result;
}
Microsoft(R) C/C++ Optimizing Compiler has encontered a problem needs to close. We are sorry the inconvenience.
...
Please tell Microsoft about this problem.
...
...
Send Report Later Dont Send
-- modified at 9:49 Wednesday 5th September, 2007
|
|
|
|
|
I added this to a class in an existing project and it compiles fine in VS2005 XP Pro
generic<class T>
T DMe::Show(T value)
{
System::Console::WriteLine("DMe::Show");
return value;
}
|
|
|
|
|
Yeah I know I want to know why compiler shows a message for + for for other operation it shows an error?
|
|
|
|
|
|
The code shouldn't compile because of this line: result = value + 2; since not all objects define the plus operator.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Pls i need a help; i would to write a simple program in c++ console that will calculate every maths equation and functions( Simultaneous Equations;quadric equation; linear equation ...)
Thanks
|
|
|
|
|
You're using .NET to do this ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Oh right....
Schools out for back from summer
Schools back for semester
Code Project's been blown to pieces.
No more thinking
No more logic
More of Just F***ing Google it.
|
|
|
|
|
\m/ \m/
Rock and roll, man.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
So how can u help me to solve this problem anyway; anny programming language will go for it, u know i m a beginner in programming.
Thanks
|
|
|
|
|
My point is, if you're not using .NET, you're in the wrong forum. Your question is not a beginner question. Buy a book on C++ and work through it before you start choosing arbitrary tasks to achieve.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi
I have just done a calculator program by c
it includes: arbitrary equation; quadric equation; linear equation; cubic equation, a set of equations, complex mode ..etc.(using graphics)
if you want source code, send me your mail.
ubri
|
|
|
|
|
uri_130688@yahoo.com
ubri
|
|
|
|
|
please can i have the source code?
Thank you
|
|
|
|
|
I think i need your email to send you my code
ubri
|
|
|
|
|
urbdoz@yahoo.com
Please can u codes run in C++?
Thanks
|
|
|
|
|
Would u plz help me to do this assembly language question?
Write a program that diaplay a volcabulary at 100 random screen lpcations with differnt colors,using a tining delay of 100-milliseconds.The colors are numbered from 0 to 15,so you can use a loop to generate differnt colors.
*Use the GetMaxYY procedure to determine the current size of console window.
1.Ask the user to input their name.
2.Calculate the time they use to input into milliseconds.Then,multiply this time by 100 to get a bigger number.Save and name this number as MyIntervalTime.
3.Declare 100 vocabularies for display.
4.The Interval time between each volcabulary is MyIntervalTime.
5.Randomly get one volcabulary from database above.
6.Display them one-by-one until we have 10 vocabularies in the same screen.Do not forget to change colors for each vocabulary.
7.When we have 10 vocabularies,clear screen.Then,start from displaying only one vocabulary.
Thx u so much for do this question
|
|
|
|
|
Would u plz help me to do this assembly language question?
Write a program that diaplay a volcabulary at 100 random screen lpcations with differnt colors,using a tining delay of 100-milliseconds.The colors are numbered from 0 to 15,so you can use a loop to generate differnt colors.
*Use the GetMaxYY procedure to determine the current size of console window.
1.Ask the user to input their name.
2.Calculate the time they use to input into milliseconds.Then,multiply this time by 100 to get a bigger number.Save and name this number as MyIntervalTime.
3.Declare 100 vocabularies for display.
4.The Interval time between each volcabulary is MyIntervalTime.
5.Randomly get one volcabulary from database above.
6.Display them one-by-one until we have 10 vocabularies in the same screen.Do not forget to change colors for each vocabulary.
7.When we have 10 vocabularies,clear screen.Then,start from displaying only one vocabulary.
Thx u so much for do this question
|
|
|
|
|
1 - don't double post
2 - don't post off topic questions - this is the forum for C++ with .NET, assembly is definately off topic
3 - don't ask us to do your homework for you
Surely anyone who is being given an assembly language project for homework would be able to at least attempt it before asking for help ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I'm encountering some strange behavior in a C++/CLI app I'm writing. I'm wondering if anyone has seen anything like this before:
The app interface uses the .NET designer, but the key data structures are all in native C++. Specifically, I use unmanaged array of a data class. All of my data loading and saving is binary. It all works fine except for one odd behavior: If the saved binary file is created when running the app through the IDE, trying to use the file when running the app directly produces an AccessViolationException. If the saved binary file is created when running the app directly, trying to use the file when running the app through the IDE produces the same AccessViolationException. Note I get no such exceptions if I stick to one environment or the other.
When I say "use the file", I mean load it and try to do further processing. Through the debugger I've been able to determine the file loads fine. The exception occurs when I try to do anything with it. For example, in a button click event on the managed form, I call something like MyUnmanagedDataPointerArray[Index]->DoSomething(). The exception occurs when the DoSomething() method is invoked. Remember, this does NOT happen if I run strictly in IDE or strictly direct. Knowing this seems to rule out any instructions in DoSomething() as being the problem.
So to boil it all down, is anyone aware of anything that could cause BinaryReader and BinaryWriter to behave differently in the IDE versus running the application directly? Why would a binary file, created when running in the IDE and re-usable when running in the IDE, not be re-usable when running the EXE directly????
FYI, I'm using Win XP Pro SP2, VS 2005 SP 1.
|
|
|
|
|
A little update on this....
I used the step-trace to try and get a little more information. It's like the compiler messes up the method memory addresses. The problem only occurs when trying to invoke the DoSomething() method. I can invoke DoSomething2() just fine. But when I try to invoke DoSomething(), instead of the step trace moving into MyClass::DoSomething(), it moves into the system file "towupper.c" and tries to call extern "C" wint_t __cdecl towupper (wint_t c).
How can my class method address get crossed with a system function -- especially when DoSomething() is purely a mathematical routine?
|
|
|
|
|
Could you please help me to understand what ( str_time.substr(11,2) != "00" ) would do
in this code. And what normalise does in this code?
unsigned long normalise(unsigned long input_time)
{
bool finished;
// This produces a formatted time string like:
// Thu_Nov_24_18:22:48_1986
string str_time = format_time( input_time );
while( str_time.substr(1,3) != "Sun")
{
input_time -= 24*60*60;
str_time = format_time( input_time );
}
while( str_time.substr(11,2) != "00" )
{
input_time -= 60*60;
str_time = format_time( input_time );
}
while( str_time.substr(14,2) != "00")
{
str_time = format_time( input_time );
input_time -= 60;
}
while( str_time.substr(17,2) != "00")
{
input_time -= 1;
str_time = format_time( input_time );
}
return input_time;
}
Thank you.
Thank you
|
|
|
|
|
Hi,
Substring is explained in the .NET reference manual (use MSDN or Google).
this strange piece of code takes a datetime number and tries to find the previous
sunday midnight, using lots of strings: it repeatedly converts to string, then
checks for "Sun" in it, takes away 24 hours, etc; then forces the hour to "00", etc.
Obviously all the while loops are redundant: if the hour is 23, then subtracting 23*60*60
could happen straight away; etc.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|