Programming :: Passing The Char * Vector Argument?
Jun 19, 2010
I am trying to simulate a shell. So what I do is checking of having the parameters from standard input, suc as "/bin/ls -l /home/france/Documents", and then passing them to function execute, which at some point calls execvp(argv[0],argv)The problem is that I don't succeed in using these arguments, while if I call execvp(paramList[0],paramList) it works!!!! Where paramList is exactly what I would put on standard input, but defined statically.
Code:
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
[code].....
View 2 Replies
ADVERTISEMENT
Apr 26, 2010
Below I've presented the declaration, definition and the calling method of a function w.r.t pass by reference:
Declaration
Code:
void getUnpackedMsg (unsigned char &data, unsigned int numberOfBits);
Definition
line 278: Shown in RED
Code:
void packedMessage :: getUnpackedMsg (unsigned char &emptyArray, unsigned int numberOfBits)
{
...
...
printf ("
[code].....
View 3 Replies
View Related
Oct 30, 2009
I have a template similar to the following.
Code:
template <charT>
virtual void do_get_date(charT* = "str")
{ ... }
As you can see we have a problem. If we use a wchar_t instead the string wont be formatted right we need to prefix L in front. If we use char16_t we need to prefix a u in front. Is there a was to make the generic without resorting the the std::string class?
View 2 Replies
View Related
Apr 14, 2010
I want to use vfprintf with the char * on 64-bit. Here is the sample code:
[Code]...
In this code, I am getting warning: passing argument 3 of vfprintf from incompatible pointer type I have done sizeof(va_list) on 64-bit, and its 24 bytes. I don't know how am I suppose to use the va_list this way.
View 1 Replies
View Related
Jul 13, 2011
i have this warning "differ in signedness".
[Code]...
so i was getting this error. im thinking it may be because of somewhere i declared unsigned and signed so this signedness warning occurring.
Code:
switcase.c: In function ImplementDebugCmd: switcase.c:385: warning: pointer targets in passing argument 1 of STRING_stricmp differ in signedness
View 1 Replies
View Related
Mar 4, 2010
m getting the following error when trying to compile:Quote:
$ make
g++ -march=athlon64 -O2 -pipe -fomit-frame-pointer -msse3 -c -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"undelete"' -DHAVE_SVDRP -I../../../include undelete.c
[code]...
View 14 Replies
View Related
Nov 4, 2010
Programming in C.I have two char arrays.char buf1[1024];char buf2[1024];Aren't buf1 and buf2 also pointers?I read in 1024 bytes into buf1 which contain about 300 bytes of characters with newlines. The data is basically a few English sentences. I'm trying to scan buf1 for newlines and then stop at the 1st newline and copy the rest of the data from that 1st newline into buf2.So I run a for loop to look for that new line.
Code:
for(i=0; i<1024;i++) {
if((strcmp(&buf1[i], "
[code]...
View 8 Replies
View Related
Jul 9, 2010
I am having trouble with the following exception class.
Code:
/**Standard Exception
*
*@description
*@update
*@changes
[code]....
Line 43 points at the snprintf() command.I think the error has to do with the function being virtual and the const after the function definition, however although I have been looking really hard I have not being able to find the reason nor the solution to the problem.
One workaround that I know is moving the block of source withing the virtual function, in the constructor, however having read around (boost library exceptions tutorials) it specifically said that formating of errors messages should not take place withing the construction of objects because we are risking throwing an exceptions and messing up the flow order.
View 11 Replies
View Related
Feb 14, 2011
i define variable of type char (range -128 to 127). when i tried to print the value after assigning a -ve value to it it displaying a +ve value of that -ve value(256+value).
View 3 Replies
View Related
Jul 5, 2011
With this I may remove the last emtpy char which is not visible, coming from net, windows, ...
Code:
echo "$mystringwindowsorotherwithemptylastchar" |sed s/.$//
However if there are not then it makes a problem and delete effectively an existing char.
Code:
echo "klklj" |sed s/.$//
klkl
Anyone would have a solution for SH?
View 2 Replies
View Related
Mar 6, 2010
I have a number of projects, say test1, test2, test3,. I want to make and install all of them in exactly the same way; so I would like to say
make test2
make install test2
with the same Makefile.
In other words, I would like to pass the argument test2 (or just 2) to the Makefile, so this is taken as the target for make or make install. This must be a common wish; but I don't see any appropriate option with "man make" on my Fedora-12 system.
View 1 Replies
View Related
Mar 4, 2010
is it possible to convert a variable from char * to unsigned char ?
View 5 Replies
View Related
Jun 17, 2011
I'm trying to install a program (MOPAC2007) from the source code which is a 32-bit program, but I get the following errors:
[code]...
I have installed the 32-bit libraries (gcc-gfortran.i686, glib.i686, libstdc++.i686).
View 1 Replies
View Related
May 29, 2010
I've never programed shell scripting.
Code goes like so:
I simply want to read a file "data.txt" line by line Then char by char and add them into a result var. The file is supossed to always contain numeric values
View 8 Replies
View Related
Mar 20, 2011
I'm not really a C++ noob at all, but I am a little rusty at the moment. Still, I CANNOT figure out what is wrong with the following code. I'm using Visual Studio 2010.
Code: #include <iostream>
#include <fstream>
#include <vector>
#include <string>
[Code]....
I THINK I got all of the pertinent code. Anyway, it fails at the *** line. I CANNOT figure out why. If I modify it to be linein.size()-30, it STILL gives me an error. That makes zero sense.
View 3 Replies
View Related
Sep 3, 2010
i need to implement a Set class(like in stl) using a vector.Here is my code that doesnt work corectly:
Code:
#include <iostream>
#include <vector>
template<class T>
class Set
{
[Code]....
View 2 Replies
View Related
Jan 17, 2011
is there any problem that might rise by by having a vector as a member of struct in c++ as follows.ex.
struct A
{
int a;
[code]...
View 2 Replies
View Related
Mar 4, 2011
I have a vector of octets that needs to be converted to a std string. I'm currently doing it this way:
Code:
stringstream ss;
for (unsigned int i=0; i < data.size(); i++
{
ss << data[i];
}
string s_data = ss.str();
This works, but is there any better way to do it?
View 2 Replies
View Related
Mar 23, 2010
Is it not possible to declare a vector inside a C++ class ? Have a look at the following code:
Code:
#include <stdio.h>
#include <iostream>
#include <malloc.h> // malloc
#include <strings.h> // bzero
[code]....
View 2 Replies
View Related
Sep 8, 2010
I have two functions:
Quote:
void func1(std::string &s)
{
s.clear();
}
[code]....
Is there a way to create one template function for both vector and string that would clear them?
View 4 Replies
View Related
Jun 6, 2010
I am trying to make a simple vector test program, but i can't compile it. Here is the code:
Code:
import java.util.*;
class Vec {
public static void main(String args [ ]) {
[Code]....
View 2 Replies
View Related
Sep 2, 2010
I'm making a multimedia library to speedup vector and matrix computation. But I'm getting a strange error, in this code
[Code]....
View 4 Replies
View Related
Jan 21, 2011
I'm trying to write some code that involves creating a function to return a vector iterator.I'm not sure what is wrong.
Code:
template <typename T> class VectorTemplate
{
[code]....
View 4 Replies
View Related
Jan 6, 2010
I've modified a program to show * instead of letters when typing a password. I'm trying to make it so that when pressing backspace a * will be removed.Here's a rough example. The problem is that when trying to do this in the real program,' is not recognized as backspace.
View 6 Replies
View Related
Jul 16, 2011
I'm writing the Diffie-Hellman key exchange system using GMP to handle big integers. For the most part, everything works. I can convert the string to mpz_t, set up the keys and everything, and encrypt it fine. Its the decrypting I'm having issues with. What I'm using is mpz_xor() for both. To encrypt I'm doing mpz_xor(buffer, mpz_of_text, secret_key), and to decrypt I'm doing mpz_xor(buffer, mpz_of_cipher, secret_key).
For one character, it semi-works...it'll decrypt it fine, but it'll return it as it's ASCII value (i.e.: if I encrypt "A", it'll decrypt it as 65). Which, I can easily just do sprintf(decrypted_buffer, "%c", 65) for example and be fine. But, when I'm sending text bigger than one character, the encryption for AB gives me something like 1061043 after running the decrypting xor on it.
Has anyone ever done this before or can point me in some directions? Perhaps other algorithms to try? I know XOR isn't the most secure encryption method to use, but at the time I wasn't sure what else to use. I'm really just having a hard time trying to convert a mpz_t to a character string. I've looked at mpz_get_str() and it works before running encryption (i.e.: using mpz_set_str() to create a mpz of a string, then calling mpz_get_str() to change it back). Maybe my XOR method is wrong? Here's the code I'm using:
Code:
/**
* str2mpz()
* b The current buffer of text to convert [in]
* m The mpz_t variable to store converted text [out]
[code]....
View 9 Replies
View Related
Jan 27, 2011
I have a char*[] array:
Code:
char* myarray[] = {"Hello", "there!", "LQ"};
and I wish to use/ write a function to find the number of elements in myarray (in this case, its 3).
*equivalent of .NET's array.size() that returns number of elements in array
How do I achieve it?
View 7 Replies
View Related
Jul 18, 2010
What could be a command to erase from the cursor up to the first non-blank char in vi (or vim)?
View 3 Replies
View Related
Oct 17, 2010
I am a dummy in C programming. I have a problem with copying the array of 64 elements of unsigned char to array of 8 element of uint64_t. For example:
unsigned char p[64]
uint64_t Data[8];
memcpy (&Data, &p, 64);
I am not sure if it is right. Please help me. Thanks a lot.Moreover, do both p and Data have 64 bytes?
View 2 Replies
View Related
Mar 6, 2011
This works for "char" but i need "char*",how do I do it?
Code:
char* tk = (char*) calloc(ctk+1,sizeof(char*));
Error when I use it:
Code:
error: invalid conversion from har* to har
View 2 Replies
View Related
Mar 19, 2010
I would like to create a small C tool. I encounter a problem of how to make a function to check an input chars contains numbers (started from the second element).
Some samples:
char *mychar= "a3547"; (The result of function checking this is true)
char *another_char = "t6548"; (The result of function checking this is true)
char *next_char = "appl3"; (The result of function checking this is false)
char *new_char = "b1aa3"; (The result of function checking this is false)
View 4 Replies
View Related