|
Yes! To deceive the enemy! You're right!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Why don't you post the piece of code you have a problem with?
|
|
|
|
|
Coz we all know u r a (in)famous corporate espionage guy, sir.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
OK, I admit it. We have been looking for the calculator code for years. Busted...
|
|
|
|
|
Michael Schubert wrote: We have been looking for the calculator code for years
Well, you should know: there is NO code inside, there's a little man...[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
mazizi wrote: i search in MSDN but it was useless!
I suspect it was your search criteria that was. Did you consider atoi() ? See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Could someone pls explain the below question?
Q1 : In line1 the second parameter is referece to integer constant.
If so how is the value in 'x' changed to 4
Question:
#include<iostream>
#include<conio.h>
using namespace std;
int mani(int (&arr)[10], const int& x)
{
for (int i = 0; i < 1; ++i)
arr[i] = arr[i] + x;
return x;
}
int main(){
int arr[10] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
cout<<mani(arr, arr[0]);
}
|
|
|
|
|
Member 3974347 wrote: If so how is the value in 'x' changed to 4
Since the variable x is a reference to the a[0] , when ever you use x, keep in mind that you are actually using a[0] itself. And in the for loop, when the value of i = 0 , you chnages the value of a[0] and so the x will also points to new value.
Defining the x as constant only prevents directly chaging the value of x, using the x variable itself. something like x = a[2]; will be shown as error.
|
|
|
|
|
Well, "x" an indeed an "integer constant" from the our point of view: by taking a constant reference, we obligate ourselves not to change the value of "x", we can only read it. However, it does not mean that the value of x has to be constant, it's just that _we_ can't modify the respective memory area through this variable named "x". If it's not a constant actually, then anyone else, or even us, through an other alias can modify the memory area (in this example through the non-const reference to the array), the modified value of course reflecting also when accessing the value of x.
So, in this example, "x" is just an alias to the first element of the "arr" array marked const (=you can't modify the value through me), but since the function takes the array by reference (thereby obtaining an alias for the original "arr" array) and changes its first element (remember, the array is a non-const reference, it can be changed), it actually changes the first element of the original, global "arr" array, but "x" is still just an alias for this, thereby its value must be 2 + 2 = 4.
|
|
|
|
|
i m new to programing in mfc..i developed an SDI application.when i click file->open menu then file open dialog is not showing.wat could be the prblem.
|
|
|
|
|
did u do any changes in the application?
|
|
|
|
|
thanks i solved it..actually i had override onfileopen()and did not code it to show the file dialog.
|
|
|
|
|
Hi All
I have this string /work1/data/xxxx/yyy/file_name.txt
how to extract "only" the path name without the file name in C++
thanks
|
|
|
|
|
Try out splitpath API, it will meet your requirement, check out MSDN for the syntax
Thanx
|
|
|
|
|
No , I need C++ buitl-in class or a play around not Microsoft C++
|
|
|
|
|
you need to create your own function for this. go ahead and try it. if you are stuck ask for help.
|
|
|
|
|
|
Use the following line of code.
dirPath =fullFilePath.substr(0,(fullFilePath.find_last_of(L"\\")));
Prafulla Vedante
|
|
|
|
|
traverse the char array from end (in reverse way) till you see a / and then replace '\0' there.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
const char * path = "/work1/data/xxxx/yyy/file_name.txt";
const char * filename;
filename = path+strlen(path);
while (filename != path && *(filename) != '/')
filename--;
if ( filename != path) filename++;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If you want simple hack, then
std::string s = "/work1/data/xxxx/yyy/file_name.txt";
std::string::size_type lastSep = s.find_last_of('/');
if (lastSep != std::string::npos)
s.erase(lastSep);
If you want a nice cross-platform for manipulating file paths, I'll recommend Boost.FileSystem[^], where you can do this:
boost::filesystem::path justThePath("/work1/data/xxxx/yyy/file_name.txt");
justThePath.remove_filename();
Oh - and it'll happily deal with Windows vs Unix path conventions.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
ksaw123 wrote: how to extract "only" the path name without the file name in C++
Have you tried PathRemoveFileSpec() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi!
I've been experimenting with custom flow control techniques for bulk transfers over UDP when I discovered something very weird. Please take a look at the following code: it just sends UDP datagrams of size 1400 bytes in an endless loop to some IP address.
SOCKET sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
sockaddr_in targetAddr;
targetAddr.sin_addr.s_addr = inet_addr( "...some IP..." );
targetAddr.sin_family = AF_INET;
targetAddr.sin_port = htons( 1337 );
char arr[1400];
long long sent = 0;
while( !kbhit() )
{
for( int i=0; i<1000; ++i )
{
long res;
if( (res=sendto( sock, arr, 1400, 0, (sockaddr*)&targetAddr, sizeof( targetAddr ) )) == SOCKET_ERROR )
{
printf("Error: %d\n", WSAGetLastError() );
return -1;
}
sent += res;
}
printf("\r%d MBs sent", (long)(sent >> 20) );
}
When I run the program, every sendto() call succeeds and reports having sent 1400 bytes of data. The interesting thing is that I get a transfer rate of just about 50 MB/s but 100% CPU usage on one core (mostly kernel-mode). Now:
-- my computer is connected to an Ethernet 100BaseTX network, which obviously does not support the transfer rate above, so datagrams get already lost before even reaching the network. Why does sendto() then reports having sent the data, what is more, why does it not block when I/O buffers fills up? (The documentation says that it should.)
-- how on Earth can someone utilize the full potential of a - say - Gigabit Ethernet network if just sending data even at half of its capacity already causes maximum CPU load?
So, what am I doing wrong, why on Earth does sendto() takes so long?
Any suggestion is very welcome, thanks,
clayman
P.S.: I've run a test with 140 bytes of data each time, and the transfer rate basically dropped to 5 MB/s -- so the _number_ of sendto() calls seems to be the bottle-neck.
|
|
|
|
|
|
Yes, I do, but I sent the program to some fearless friends without firewall, and they experienced similar results on Windows XP. Meanwhile, I tested the code on other OS-es as well.
So the measurements are for 1400 byte UDP daragrams:
- Windows XP SP 3 (w/ fw): 66 MB/s, 100% CPU-usage/core (mostly kernel)
- Windows 7 RC1 (no firewall): 11.5 MB/s, but only 20% CPU-usage/core, seems to take interface capacity into account (which is, after all, what I would expect in the first place)
- Ubuntu 8.10 on VMware with Tools: 120 MB/s, 100% CPU-usage/core (mostly kernel)
In contrast, I've been able to push data through a loopback TCP connection at 330 MB/s on WindowsXP/CLR, and nearly 500MB/s on Ubuntu.
modified on Tuesday, July 7, 2009 11:13 PM
|
|
|
|
|