Hello everybody, is there somebody that can help??
I'm having string (my example in string 55+22)that must be inputed by keyboard
.. the first part I've done to put 55 to another array 2(with strtok function)
Now that I was tries for many hours to put 22 to an other one was failed :@:yawn::sad::-/
if there is anyone that can put
char firststring[] = [55+22]//put to another string or copy
In such way that each time program work it finds + and copies 22
it is easy

it is easy

I know. Could you show us your attempt?

I know. Could you show us your attempt?

#include<cstdlib>
#include<cstdio>
#include<cstring>

void input(char *zangvac);

int main (void)
{
//////////////////////
char *text0 = new char[300];	
gets(text0);
int b = strlen(text0);
char *zangvac = new char[b +1];
strcpy(zangvac, text0);
delete [] text0; printf(zangvac); printf("\n");
///////////////////dynamic
input(zangvac);

}
void input(char *zangvac)
{
char *meshok1 = new char[150];
*meshok1 = 0;
meshok1 = strtok(zangvac,"+");
printf("%s", meshok1);
int length1 = strlen(meshok1);
//strncpy(meshok1, zangvac, P);

char *meshok2 = new char [150];//in meshok 2 must be 22 or smth else you type
//int c = strspn(zangvac, "+");

printf("%d", c);
char *gumareli_1 = new char [length1+1];
strcpy(gumareli_1, meshok1);
//printf("%s", gumareli_1);
char *gumareli_2;
//put meshok1 to gumareli_1, meshok2 to gumareli_2 and then plus it 
//using atoi functions ok?
//could you?
//don't forget to type discription plz
//and if you want add me to google friend(zz follow) list "Mikael Arakelyan"
}

Are you sure this is C code?
When compiling with a C compiler:

test.c:1:18: cstdlib: No such file or directory
test.c:2:17: cstdio: No such file or directory
test.c:3:18: cstring: No such file or directory
test.c: In function `main':
test.c:10: error: `new' undeclared (first use in this function)
test.c:10: error: (Each undeclared identifier is reported only once
test.c:10: error: for each function it appears in.)
test.c:10: error: syntax error before "char"
test.c:11: warning: implicit declaration of function `gets'
test.c:12: warning: implicit declaration of function `strlen'
test.c:13: error: syntax error before "char"
test.c:14: warning: implicit declaration of function `strcpy'
test.c:15: error: `delete' undeclared (first use in this function)
test.c:15: error: syntax error before ']' token
test.c:15: warning: implicit declaration of function `printf'
test.c:12: warning: unused variable `b'
test.c: In function `input':
test.c:22: error: `new' undeclared (first use in this function)
test.c:22: error: syntax error before "char"
test.c:24: warning: implicit declaration of function `strtok'
test.c:24: warning: assignment makes pointer from integer without a cast
test.c:29: error: syntax error before "char"
test.c:32: error: `c' undeclared (first use in this function)
test.c:33: error: syntax error before "char"
test.c:26: warning: unused variable `length1'
test.c:29: warning: unused variable `meshok2'
test.c:36: warning: unused variable `gumareli_2'

When compiling with a C++ compiler:

test.c: In function `void input(char*)':
test.c:32: error: `c' was not declared in this scope
test.c:29: warning: unused variable 'meshok2'
test.c:32: warning: unused variable 'c'
test.c:36: warning: unused variable 'gumareli_2'

Just to verify: Your object is to create a program that reads strings of the forms "5+3+7", "9+2", "5+9+3+1+4", etc. ? And you want to store every value separated by a '+' sign into another character array? Or do you just want to store a pointer to it?

[EDIT]
Could you post a fixed version of your code?
As you can see it didn't compile.
[/EDIT]

I don't know why is your compiler angry but
with my visual studio 2010 it have been workin
..I wonder if c code can't work with c++?
and If you can send me private message plz

#include<stdlib.h>
#include<stdio.h>
#include<string.h>

void input(char *zangvac)
{
    char *meshok1 = new char[150];
    *meshok1 = 0;
    meshok1 = strtok(zangvac,"+");
    int length1 = strlen(meshok1);
    char *meshok2 = new char [150];
    //int c = strsp//whatever write here the answer for my question here 
    //printf("%d", c);//I'd understand and write myself ok?

    char *gumareli_1 = new char [length1+1];

    char *gumareli_2;
}
//put meshok1 to gumareli_1, meshok2 to gumareli_2 and then plus it 
//using atoi functions ok?
//could you?
//don't forget to type discription plz
//and if you want add me to google friend(zz follow) list "Mikael Arakelyan"
}

No.....
But tell you what here is an example of how to use strtok function http://www.cplusplus.com/reference/clibrary/cstring/strtok/

So if the user can enter strings which just have 2 operands then the code is quite simple. Use strtok and store each operand in each array ...
But if the user can enter expressions which have n operands then its a bit tricky

commented: Good :) +8

You are welcome. Mark the thread as solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.