Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Semrush - keyword research tool

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Teach Your Child To Read

Disclosure: My content contains affiliate links.

31,647 questions

41,700 answers

573 users

How to convert a specific row of a matrix to a string in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>

void convert_int_array_to_string(int arr[], int size, char str[]) {
    for (int i = 0; i < size; i++) {
        sprintf(str + strlen(str), "%d ", arr[i]);
    }
}
  
int main() {
    int arr[] = { 4, 7, 5, 18, 29, 0, 3 };
    char str[128];
    
    int size = sizeof(arr) / sizeof(arr[0]);
  
    convert_int_array_to_string(arr, size, str);
      
    puts(str);
  
    return 0;
}
  
  
  
/*
run:
  
4 7 5 18 29 0 3 
  
*/

 



Learn & Practice Python
with the most comprehensive set of 13 hands-on online Python courses
Start now


answered Jul 9 by avibootz
edited 6 days ago by avibootz
...