I got it to work doing this, not sure if this is the best way or not?
for (int i = 0; i < phrase.size(); i++) {
found = phrase.at(i).find("ssh",0);
if (found != string::npos) {
...
Type: Posts; User: bradleyd
I got it to work doing this, not sure if this is the best way or not?
for (int i = 0; i < phrase.size(); i++) {
found = phrase.at(i).find("ssh",0);
if (found != string::npos) {
...
This is what I have so far.
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
int main(int argc, char** argv)
I guess I should have worded it better. The string will always start with ssh, whether it is just ssh or ssh [email protected]. So in crude regexp format:
^ssh*
thanks again
I tried using find but it only returns ssh. So if there were 10 occurences of of the word "ssh", they are not all just ssh. Some are ssh [email protected]. I am trying to return all strings that contain...
the vector is a vector of strings. I used this to populate it:
while (getline(infile, line))
{
file.push_back (line);
}
Thanks for the response.
Hello,
Is there a way to search a vector and return all occurrences of a string. I have read a text file into a vector and want to search throught the vector. For example I am searching the vector ...
I will give it a try and post back. Thanks again.
Will the data still come out in descending order? I gues I am unsure what you mean.
Thanks for the reply.
Here is the osrt method I am using. I created an array of int's to try it out for now.
I am passing it month[] which is an array of int's(1-12) and the rainfall amounts the user has entered, plus...
this is a class assignment and we have not gotten to struct's yet.
thanks for the reply. Unfortunately I can't use struct's. I have to do this with just arrays, or vector's.
hello everyone,
I was wondering if there is way to sort two different arrays of different data types without struct's.
For example lets say you have an array of doubles that represent rainfall...
ok that makes sense. Thanks to everyone.
Take Care.
no your changes worked perfect. I was just a little confused. If I call get_l(); in main, it does return current user. But when I try to call it from sprintf, I get the error. I just wanted to know...
that was it, I had it return(buff), but it gave me an error about returning local variable. So I switched it to what I submitted. When I put get_l(); in main it would return current user. I am a...
Hello everyone,
I am trying to use sprintf, but keep getting error: invalid use of void expression
sprintf(s,"%s",get_l());The function get_l looks like:
void get_l()
{
FILE *data;
char...
I get it,
thanks again Salem
Take care
so basically I can read the contents of /var/run/pidn.pid and that will give me the pid of the process I just started. I have tried other things like gedit in place of pppd call and it gives the...
ok, do you know how I can get the pid when I execute pppd daemon from within the code?
Thanks for the response.
Hello everyone,
I am stuck with fork(), pid, popen(). I am trying to execute a command, capture it's pid so that when I choose to stop the command I can use kill(). What I have works as far as...
the executable and files will be installed on other machines. I will not be the one installing them, so there is no telling where they will install them. I was trying to piece together a way so no...
thanks MacGyver and zacs7. fopen does look in cwd. The only problem I was having is the executable may not be in the same folder as the file it is opening to read.
hello everyone,
I can't figure out the correct way to do this. I have a function that gets the current working directory. I am using fopen to read a file, but want to use CWD function to return cwd:...
ok that makes sense, thanks MacGyver.
Pointers seem to be my weak point in C.
Thanks that worked, I kinda foggy on char *GetHome vs. char GetHome. If you want to return any string from a function do you always have use a pointer in declaring the function?
when you want to...