•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 423,540 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,195 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 999 | Replies: 2 | Solved
![]() |
Hi,
I am trying to create a method that accepts a pointer to a (static) string so that it can modify the string. I have something similar to this:
If I compile the above code, I get the following message:
warning: passing arg 1 of 'modifyString' from incompatible pointer type
How can I write a method which will allow me to modify the contents of a static string?
I am trying to create a method that accepts a pointer to a (static) string so that it can modify the string. I have something similar to this:
void modifyString(char **pstr) {
char *str = *pstr;
// Make changes to str ...
}
void doSomething() {
char str[] = "Hello World";
modifyString(&str);
}If I compile the above code, I get the following message:
warning: passing arg 1 of 'modifyString' from incompatible pointer type
How can I write a method which will allow me to modify the contents of a static string?
Last edited by Dark_Knight : Jan 13th, 2008 at 8:25 pm.
C Syntax (Toggle Plain Text)
void modifyString(char *pstr) { char *str = pstr; // Make changes to str ... } void doSomething() { char str[] = "Hello World"; modifyString(str); }
"No man's life, liberty, or property is safe while the legislature is in session." ~ Mark Twain
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the C Forum
- Previous Thread: Getting and setting cursor position in C
- Next Thread: Hiding names in static libraries



Linear Mode