Member Avatar

in my program, in insert function: void apple :: insert(string s, int a) { node *ptr; ptr = new node; strcpy(ptr->name, s); ptr->price = a; ptr->next=head; head=ptr; } this is acctually i want to do strcpy(ptr->name, s); but error is: cannot convert std::string {aka std::basic_string<char>} to char* for argument 1 to char * strcpy(char*, constant char) any one plz help debug it, fastly, i have very short time to submit my project :( thank you.

Member Avatar
0
8
Member Avatar

Hi! what is wrong with the following function? void foo(*ptr){ char buff[127]; ctrcpy(*ptr,buff); } I know that it doesn't really do something... it's for information purpose only.... Thanx!!

Member Avatar
0
60
Member Avatar

Hi, I'm writing a small C program to clean the radius radacct table, removing ended sessions records and inserting on a separated database. The problem is that MySQL C API doesn't have an easy way to insert the result of a query on another database/table directly, you have to build a custom insert statement, I'm trying to do that, I'm using strncpy to copy the fields on the result row to the insert statement char array. It works for just a few records, than it returns me a segmentation fault error, here is the piece of code where the copy …

Member Avatar
0
7
Member Avatar

how to copy pointer to pointer. char *name1; //store the value of DAVE char *name2; if name2 was a array i would have done. strcpy(name2,name1); but i dont know how to copy pointer into pointer. i was thinking some thing like this. name2 = name1? also do i need to test malloc for name2?

Member Avatar
0
3
Member Avatar

*i am trying to copy the value of ar2[10] //in main. has the value 1,2,3,4,5 in ar[10] //(in struct node). empty array so to copy the value iam not sure if i could use a strcpy for ex, strcpy(head->ar, ar2); //here is my code struct node { int ar[10]; //empty array struct node *next; }; struct node *head; void insert_list1(int[]); int main() { int ar2[10]; //let just say ar2 has the value 1,2,3,4,5 insert_list1(ar2); } void insert_list1(int ar2[]) { struct node *cur_node = head; struct node *new_node; if(cur_node == NULL) { head = (struct node *) malloc(sizeof(struct node)); if(head == …

Member Avatar
0
11
Member Avatar

trying to copy pointer in array. lets say *pointer has the value "COMPUTER". and i want to store in array[o]; note: i want to use strcat to do this and i do not want to do some thing like "array[0]" char test[10]; char *point; //has the value "COMPUTER" for(int i = 0; i < 10; i++) { test[i] = '\0'; } strcat(test, point); //store value at end of test array. so test[0] is computer for(int i = 0; i < 10; i++) { printf("%s",test[i]); } not sure why this dont work;

Member Avatar
0
5

The End.