|
Each of these functions returns a pointer to the first occurrence of strCharSet in string, or NULL if strCharSet does not appear in string. If strCharSet points to a string of zero length, the function returns string.
i SUCK with pointers so help me out here
how would I know what number of the array it would be?
thanks
|
|
|
|
|
xlntbno17 wrote:
Each of these functions returns a pointer to the first occurrence of strCharSet in string, or NULL if strCharSet does not appear in string. If strCharSet points to a string of zero length, the function returns string.
Thats What strstr function defined in string.h do.
Is you have to code your own function for that?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
What would be the best way to extract something between two substrings?
Like if I'm looking through HTML code and i want whats between <tag> and </tag>
from:
"<tag>$20.00</tag>"
i would want to extract "$20.00"
but it could be anything
|
|
|
|
|
xlntbno17 wrote:
Like if I'm looking through HTML code and i want whats between and
Hope this code work well for you!
BOOL CViewSource::Return_Element_Value(const char *lpszOriginalString, const char *lpszElementVar, char *lpszReturnValue)
{
char csOpenTag[20],csCloseTag[20];
int start_pos, ending_pos, closing_br;
int i,j;
char *pdest;
sprintf(csOpenTag,"<%s>",lpszElementVar);
pdest = ::strstr(lpszOriginalString,csOpenTag);
start_pos = pdest - lpszOriginalString + 1;
if(pdest==NULL)
return FALSE;
pdest=NULL;
sprintf(csCloseTag,"</%s>",lpszElementVar);
pdest = ::strstr(lpszOriginalString,csCloseTag);
ending_pos = pdest - lpszOriginalString + 1;
if(pdest==NULL)
return FALSE;
closing_br=start_pos+strlen(csOpenTag);
char *temp=new char[(ending_pos-start_pos)+10];
for(i=closing_br-1,j=0;i<ending_pos-1;i++,j++)
temp[j]=lpszOriginalString[i];
temp[j]='\0';
strcpy(lpszReturnValue,temp);
return TRUE;
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hello,
xlntbno17 wrote:
how would I know what number of the array it would be?
Some simple pointer arithmic will do your magic:
char* pszYourString = "This is some string";
char* pszPattern = "some";
char* pszDest = strstr( pszYourString, pszPattern );
int nPos = pszDest - pszYourString + 1;
Look in MSDN[^] for more information on strstr
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote:
int nPos = pszDest - pszYourString + 1;
There's no need to add one to the result. Doing so creates an off-by-one error.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Well, the + 1 is there in MSDN.. This position in this case, is not the zero based index to an array, but the position starting at 1.
Do VB or Pascal have zero based indices?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote:
Do VB or Pascal have zero based indices?
For VB, it depends on Option Base. Yes for Pascal.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
DavidCrow wrote:
Pascal have zero based indices?
For VB, it depends on Option Base. Yes for Pascal.
Nope, Pascal don't have ZERO based Index, Index of array in pacal start with 1!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
ThatsAlok wrote:
Nope, Pascal don't have ZERO based Index,
Actually it does:
program abc;
var
numbers:array[0..9] of integer;
x:integer;
begin
for x:=0 to 9 do
numbers[x]:=x;
end.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
DavidCrow wrote:
program abc;var numbers:array[0..9] of integer; x:integer;begin for x:=0 to 9 do numbers[x]:=x; end.
I have done pascal in First Year of my Engg Graduation. When I convert from pascal to C++ , i always face problem due to array INDEX as Pascal Index start from 1 and in C++ index start from 0. May be you are right, I havn't learn PASCAL much
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I am bit concerned over the issue of fragmentation problem due to dynamic memory allocation in real time applications that have to run for long say 1 year. How to avoid it? What if in some scenario you must dynamically allocate the memory occasionaly of different block size?
Any one here, who has developed some performance critical application which runs for long and have addressed these issues?
Thanks
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
If memory is continually allocated but never freed, the program, and probably most everythying else, will come to a halt.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
hey guys...an english guy's life between u hands..so plz help me in this..i want to make apassword for my program(in visual c++) that will be invisible for the user (like that in da mail)i mean it appears as STARS shape..i want to make this by using (STRING)if that possible ..or just any simple code..iam stuck hear guys so plz replay me as fast as u can...
|
|
|
|
|
Is it a Windows application ? If so, the text box has a password property. Set it to true, and when you type in it, it will only show ******.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thank u Mr christian for u help ..i realy apreciate u time and u opinion..i have used so simple code that make user insert username && password but my prob is i cant make password invisible for the user ( appears as stars shape)
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
void main()
{
string str1,str2;
string username ("ourteam");
string password ("cool");
cout<<"plz enter username"<<endl;
cin="">>str1;
cout<<"plz enter password"<<endl;
cin="">>str2;
if(str1==username && str2==password)
{
cout<<"hello guys"<
|
|
|
|
|
#include <conio.h>
string s;
char c;
while ((c = getch()) != 13)
{
s += c;
cprintf("*");
}
Now "s" contains the string user entered.
Do this for both username and password.
this is this.
|
|
|
|
|
Hi,
I need an efficient/simple password encryption/decryption algorithm/code so that I can use in my VC++ application.
I actually looked in the net a found various utilities but not been able to decide which one to go for?
Thanks,
|
|
|
|
|
|
I tried both the links but most of the algorithms which use XOR do not work for passwords like abcd1, abcde1, abcdef12, abcdef12ghijklmnop etc.
Do you have any other algorithms which will work for all the characters? Imean encrypt/decrypt any given data?
|
|
|
|
|
Anonymous wrote:
Do you have any other algorithms which will work for all the characters? Imean encrypt/decrypt any given data?
this link will help
http://www.codeproject.com/cpp/#Cryptography[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hello all,
I'm working on a school project to make a security program. I need to get the MAC Address from the computer. That is the "Physical Address" when you type "ipconfig/all" in MSDOS command prompt.
It is urgent and I have spent pretty much time there, but still don't know what to do. I am an amateur in programming. I'd greatly appreciate your opinion. Thanks.
~~~ Landy
|
|
|
|
|
|
I have addded a toolbar in the OnCreate method of CMainFrame as below
if (!m_UICtrlsBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_RIGHT
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_UICtrlsBar.LoadToolBar(IDR_TOOLBAR_DRAW))
{
TRACE0("Failed to OSD Controls ToolBar\n");
return -1;
}
But the handlers for this toolbar wont work when child windows are restored or maximized. In other words - in the presence of child view windows the message handler for the toolbar is not invoked. IF I minimize/close the child windows the handler works.I have posted this several times.I am still unable to figure out the actual problem.
Please let me know if my problem is not clear.
laiju
|
|
|
|
|
have addded a toolbar in the OnCreate method of CMainFrame as below
if (!m_UICtrlsBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_RIGHT
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_UICtrlsBar.LoadToolBar(IDR_TOOLBAR_DRAW))
{
TRACE0("Failed to OSD Controls ToolBar\n");
return -1;
}
IF I close the child windows the handler works.The handler wont work if the child window is minimized or restored either.
laiju
|
|
|
|