I need help someone im trying to delete the blanks of this array of strings stored in str loop but cant copy wihtout delete spaces please help some one.. thanks

void deblank(char str[MAX_STR], char result[MAX_STR])
int num; //variable to hold value for string length
int i, j; // loop control variable
// strcpy(result,str);
num = strlen(str);
for(i=0 ;i<=num; i++) // loop to store vaules in array
for(j=0; j<=num; j++)
if (str[i] != ' ')
result[j]= str[i];

It isn't neccessary a nested loop.You can do it with one loop like the following code...(Assume that j = 0 at starting)

for(i=0 ;i<=num; i++) // loop to store values in array

if (str[i] != ' '){
result[j]= str[i];


you don't need the j loop. Just delete line 10 and increment it in line 14. Don't forget to initialize j in line 5.

[edit]Just like Fox showed[/edit]

omg thank u so much i was stuck on this for like weeks im kinda new to c programming so im still learning i really appreciate the help so much your an life saver

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.