Why am I getting this error? Error expected declaration specifiers or before given?
-
#include <stdio.h> void copy_substring(char given_string[], int from_posn, int no_char, char new_string[]); main() { char crazy[5]; char given[] = "Anonymous"; void copy_substring(given[],0,3, crazy[]); } void copy_substring(char given_string[], int from_posn, int no_char, char new_string[]) { int i; for (i=0;i<no_char; ++i) { new_string[i] = given_string[from_posn-1+i]; } new_string[i] = '\0'; } I am getting this error : /home/Documents/code/c/substrToString.c|7|error: expected declaration specifiers or â...â before âgivenâ|
-
Answer:
You need to make some changes ! #include <stdio.h> void copy_substring(char given_string[], int from_posn, int no_char, char new_string[]); main() { char crazy[5]; char given[] = "Anonymous"; // void copy_substring(given[],0,3, crazy[]); copy_substring(given, 0, 3, crazy); } void copy_substring(char given_string[], int from_posn, int no_char, char new_string[]) { int i; for (i=0;i<no_char; ++i) { // new_string[i] = given_string[from_posn-1+i]; new_string[i] = given_string[from_posn+i]; } new_string[i] = '\0'; }
Bharat Khatri at Quora Visit the source
Other answers
I guess stack overflow would have been a better place to ask this question. Quora is slightly more generalised. :)
Ritwik Dey
Related Q & A:
- Why am I getting error unwrapping Optional if it has a value?Best solution by Stack Overflow
- Why am I getting error on page?Best solution by Yahoo! Answers
- Why do I keep getting an error message when I use Yahoo?Best solution by Yahoo! Answers
- Why do I keep getting communication error in chat?Best solution by Yahoo! Answers
- Why am I getting a Yahoo Mail Error?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.