So I am entering an array and a number which is the length of the array to a function called "Write" like this :
string write (int n, char t[100]) To keep it simple i would only like to write the values of the array out whit the help of this function like this:
{ int i; for (i=1;i<=n;i++) { if (t[i]=='a') { printf("%c" , t[i]); } } return 0; } In the int main() only thing I did was I used a scanf for the n variable and gave from 1 to n a 'a' string value in the array.And I called the write function string write(n,t[100]); Here is the whole "main" :
int main() { int i,n; char t[100]; scanf("%i" ,&n); for (i=1;i<=n;i++) { t[i]='a'; } string write (n,t[100]); return 0; } My question is why wont this simple program run I can enter the value of the n but won't print anything out? I must be missing something out whit the declaration's or calling of the function I am new to C++.
ishould be from0ton-1not1ton