Use this program .....
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <unistd.h>
#include <string>
int main()
{
string users[4] =
{"jill","gorege","joe_blow","john"};
string me;
// One way of finding the user...
John, you have given the separators as "," and " " in the strtok(). That is why you did not get the expected result.
strtok() function accepts a single character delimiters.
Write your own program using strstr() to do the name separation.
getlogin() used to get the current user name.
Use strcmp() function to compare two strings.
For more information, see the man pages of those two functions.
Use the following program...
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char username[20];
cin >> username; //getting the username
if ( ! strcmp(username, "jstreich"))
{
\\ do some code if the username is jstreich
}...
Hi,
1. which function in C used to find CPU time of a process?
2. time utility in UNIX gives 3 results called real time, user time and system time? Can anybody give me the definition of those times?
-GL
Hi,
I am testing the performance of one of my application. Is there any built-in command line utility available in Windows (98/XP) to find the memory usage of an application? I want to have it in a batch file such that I can automate my testing.
What are the functions in VC++ used to find the...
I don't know the exact function/class in VC. But u can try it with CFile or related classes. I am also searching the answer. If i got anything, I will post it.
You are referencing a member variable by "." operator. Its wrong. Use arrow opertor "->" in those places .
Corrected Code:
#include <stdio.h>
#include <stdlib.h>
#define NAME 10
typedef struct
{
char name[NAME];
int timeForExecution;
int timeLeft;
int...
hi hnd,
using strcpy will lead to "Segmentation fault". Because no memory allocated for the character pointer "p".
As you said this direct assignment is compiler dependent only.
The literal strings are normally stored in the stack only. So the pointer "p" will...
Hi,
Is it possible to have a structure as a key in stl-map?
Let us consider the following declaration.
struct key {
int a;
int b;
};
struct compare {
bool operator()(const struct key k1, const struct key k2) const {
return ((k1->a < k2->a) && (k2->a < k2->b));
}
}...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.