Unix/Linux Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Python Results Converted To C Struct Header File

Programming


Tags
solved

Closed    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 11-13-2015   -   Original Discussion by metallica1973
balajesuri's Unix or Linux Image
balajesuri balajesuri is offline Forum Advisor  
#! /bin/bash
 
Join Date: Apr 2009
Last Activity: 8 November 2017, 2:32 AM EST
Location: India
Posts: 1,976
Thanks: 31
Thanked 574 Times in 547 Posts
Here's a simplified and easier version:

Code:
dest = open('wp.h', 'a+')

dest.write(
'''
struct {

        char *name;
        char *fixed_version;

} filename_versions[] = {

{"moses-red-sea","1.00.03"},
{"genesis-snake","2.03"},
{"deliverance","5.0.010"},
        {NULL, NULL}
};
'''
);

dest.close()

Trick here is to use the triple quotes (''' ... ''') ; ain't python cool B-)
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Storing C++-struct in file - problem when adding new item in struct Powerponken Programming 2 11-01-2011 04:51 PM
Can't assign struct variable in header file majid.merkava Programming 1 04-11-2011 09:47 AM
Python, struct.pack Dedalus Programming 1 11-14-2010 12:45 AM
Python converted from /bin/sh shell - backup script. jzacsh Programming 0 10-24-2009 09:05 PM
Reading the header of a tar file(posix header) Tanvirk Linux 2 01-31-2008 08:50 AM



All times are GMT -4. The time now is 11:05 AM.